Primitives

Contents

Primitives#

Type

Notes

string

any string. Literal types narrow further ("red").

number

64-bit IEEE 754 float; includes NaN, ±Infinity.

bigint

arbitrary-precision integer.

boolean

true | false.

null / undefined

separate types; strictNullChecks keeps them out of other types unless explicitly added.

symbol

unique primitive identifier.

void

the absence of a return value; not the same as undefined.

never

the empty type; what a function returns if it always throws or never terminates.

any

opt-out of type checking. Avoid any; prefer unknown.

unknown

top type; must be narrowed before use.

References#

  • Casting for as, satisfies, and runtime validation.

  • Types for the runtime types these annotate.