- Published on
Day06: Exploring TypeScript Data Types
- Authors

- Name
- irisjustdoit
- @irisjustdoit
Day06: Exploring TypeScript Data Types
In the previous article, we learned about the three methods of specifying types. What types can we use? Today, let's organize the data types that TypeScript might use.
Data Type Classification
I roughly categorize them into three main types:
- Primitive Types: string, number, boolean, null, undefined
- Object Types: object, arrays, function
- Types unique to TypeScript: any, unknown, void, never, union types, intersection types, literal types, tuple, enums
TypeScript Data Type Summary Table
I spent quite a bit of time referencing websites and roughly organized simple usage methods for all types, but I haven't actually applied them in a project yet. I'll take notes while learning (please feel free to correct me if there are any mistakes). In the next few articles, I will introduce each type in detail.
| Type | Type Classification | Notes | Example |
|---|---|---|---|
| string | primitive | Defines a string type. | ![]() |
| number | primitive | Defines a number type. | ![]() |
| boolean | primitive | Defines a boolean type. | ![]() |
| null | primitive | Defines a null type, which can also be assigned to all types (not allowed in strict mode). | ![]() |
| undefined | primitive | Defines an undefined type, which can also be assigned to all types (not allowed in strict mode). | ![]() |
| object | object | Defines an object type. | ![]() |
| arrays | object | Can be represented using "type + brackets" or array generics. | ![]() |
| function | object | A function has inputs and outputs, and you can specify types for parameters (inputs) and return values (outputs). | ![]() |
| any | TS | Represents a type that allows assignment of any type. | ![]() |
| unknown | TS | Similar to any, but unknown can only be assigned to any and itself. | ![]() |
| void | TS | Represents a function that does not return any value. | ![]() |
| never | TS | Represents a type that should not exist, generally used for error handling functions. | ![]() |
| union types | TS | Union types allow defining values that can be of multiple types. | ![]() |
| intersection types | TS | Intersection types require values to conform to multiple types. | ![]() |
| literal types | TS | Certain special "values" can be used as "types." | ![]() |
| tuple | TS | A tuple combines different types into one object. | ![]() |
| enum | TS | Enum types can be used to manage multiple constants of the same series, used for state judgment. | ![]() |
Let's embark on the TypeScript data type adventure together, and remember to wear your masks 😷 and fasten your seatbelts. Let's go! For examples, refer to this link.
References
https://www.typescriptlang.org/docs/handbook/2/basic-types.html https://willh.gitbook.io/typescript-tutorial/basics/primitive-data-types https://ithelp.ithome.com.tw/articles/10223315 https://ithelp.ithome.com.tw/articles/10217384

















