Types and possible values

Name [Section]

TypeScript type

Possible values

Empty type [2.1.1] never No possible values
Unit type [2.1.2] void One possible value
Sum type [3.4.2] number | string A value from number or a value from string
Tuple (product type) [3.1.1] [number, string] A value from number and a value from string
Record (product type) [3.1.2] { a: number; b: string; } A (named) value from number and a (named) value from string
Function type [5.1.2] (value: number) => string A function number → string
Top type [7.2.1] unknown A value of any type
Bottom type [7.2.2] never No possible values (the bottom type is the subtype of any other type)
Interface [8.1] interface ILogger { /* ... */ } Object of a ...

Get Programming with Types now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.