A to Z
Glossary
Every concept in this sheet, plus the smaller terms it uses. Select a concept to open its card.
#
anyandunknownanyswitches type checking off for a value.neverandvoidvoidmeans a function returns nothing useful.
A
- Arrays, tuples and readonly arrays
string[](orArray<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,nullandundefinedare the primitive types.
S
- Strict null checks
- With
strictNullChecks(part ofstrict),nullandundefinedare separate types that must be listed explicitly, as instring | null, and handled before use. - Structural typing
- TypeScript compares types by shape, not by name.
T
- The
satisfiesoperator expr satisfies Tchecks that a value fitsTwithout changing the value's inferred type.- Type assertions and non-null
! value as Ttells the compiler to treat a value asT;value!says it is notnullorundefined.- Type checking and type erasure
- TypeScript is JavaScript plus a static type system.
- Type inference
- The compiler infers types from values:
const n = 3is3,let n = 3isnumber, and a function's return type comes from what it returns.
W
- Widening and
as const - Mutable bindings widen literals:
let m = 'GET'isstring.