Typescript Foundations / Basic Types

Primitive types

👉 Primitive types represent simple, immutable values.

👉 They’re the same core types you see in JavaScript — but with TypeScript’s type safety!


⚡ List of TypeScript primitive types

Type

Description

Example

string

Textual data

"hello", 'world', template

number

All numbers (integers, floats, NaN, Infinity)

42, 3.14, -7

boolean

True or false values

true, false

null

Represents an intentional absence of value

null

undefined

A variable that hasn’t been assigned

undefined

bigint

For very large integers

9007199254740991n

symbol

Unique identifiers

Symbol("id")



💡 Notes

TypeScript infers these types if you assign a value at declaration:

let name = "John";  // TypeScript knows this is a string

null and undefined are their own types, but often combined in union types:

let value: string | null;

bigint requires ES2020 or newer in tsconfig.json.

symbol is often used in advanced scenarios (e.g., object keys).


⚡ Summary

Primitive type

Example value

string

"hello"

number

42, 3.14

boolean

true

null

null

undefined

undefined

bigint

12345678901234567890n

symbol

Symbol("key")