
· typescript · 1 min read
TypeScript primitive types
My simple memo about TypeScript primitive types.
Here are primitive types :
- number
- string
- boolean
- bigint
- symbol
- undefined
- null
But wait!
These primitives types are actually JavaScript types.
I love how elegant TypeScript is. ❤️
Because it’s a superset of JavaScript, it doesn’t try to reinvent the base types, and just accept JS basic types as TypeScript basic types.
Yes, they are the same.
So this is correct :
function saySomethingClever(n: number, b: boolean): string {}
You can explicitly use JS primitive types.
BTW you probably already heard about null and undefined, but probably not about bigint and symbol.
You can view the bigint docs and symbol docs on MDN.
At that point you should try to ask “but where are object” ?
That will be the topic for another article.
Best,
David.