TypeScript

Sefism.

A to Z

Glossary

Every concept in this sheet, plus the smaller terms it uses. Select a concept to open its card.

#
any and unknown
any switches type checking off for a value.
never and void
void means a function returns nothing useful.
A
Arrays, tuples and readonly arrays
string[] (or Array<string>) is a list of any length.
C
Contextual typing
When a function or literal is written where a type is already expected, such as a callback argument, TypeScript infers its parameter types from that context.
E
Excess property checks
When you pass an object literal straight to a typed slot, extra properties the type does not declare are an error.
O
Object types and optional properties
An object type lists property names and their types.
P
Primitive and literal types
string, number, boolean, bigint, symbol, null and undefined are the primitive types.
S
Strict null checks
With strictNullChecks (part of strict), null and undefined are separate types that must be listed explicitly, as in string | null, and handled before use.
Structural typing
TypeScript compares types by shape, not by name.
T
The satisfies operator
expr satisfies T checks that a value fits T without changing the value's inferred type.
Type assertions and non-null !
value as T tells the compiler to treat a value as T; value! says it is not null or undefined.
Type checking and type erasure
TypeScript is JavaScript plus a static type system.
Type inference
The compiler infers types from values: const n = 3 is 3, let n = 3 is number, and a function's return type comes from what it returns.
W
Widening and as const
Mutable bindings widen literals: let m = 'GET' is string.
10 · Glossary, A to Z10 / 10