Types#
TypeScript’s type system is structural: two types match if their
structures match, regardless of name. Build programs out of
primitives, object structures, unions, intersections, and a handful
of generic operators (keyof, typeof, Pick, Omit,
Partial, conditional types) that compute types from other
types.
For the lexical surface that produces these types, see Syntax. For class-shaped types, see OOP.
Pages#
string, number, bigint, boolean, null,
undefined, symbol, void, never, any,
unknown.
Inline annotations, type aliases, interface.
T[], readonly T[], fixed-length and labelled tuples.
A | B, A & B, discriminated unions.
One-value types; as const; template literal types.
<T> slots, extends constraints, generic classes.
keyof, typeof, Pick, Omit, Partial,
ReturnType.
Conditional types, infer, mapped types.
as assertions, satisfies, zod for runtime
validation.
References#
Syntax for the surface that introduces type annotations.
Operators for
typeof,keyof,in,satisfies,as.OOP for class-shaped types and generic classes.
Functions for generic functions and type guards.