Appendix B. Type Utilities
TypeScript’s type utilities come bundled into its standard library. Table B-1 enumerates all of the available utilities at the time of writing.
See es5.d.ts for an up-to-date reference.
| Type utility | Use it on | Description |
|---|---|---|
|
Class constructor types |
A tuple of a class constructor’s parameter types |
|
Union types |
Exclude a type from another type |
|
Union types |
Select a subtype that’s assignable to another type |
|
Class constructor types |
The instance type you get from |
|
Nullable types |
Exclude |
|
Function types |
A tuple of a function’s parameter types |
|
Object types |
Make all properties in an object optional |
|
Object types |
A subtype of an object type, with a subset of its keys |
|
Array, Object, and Tuple types |
Make all properties in an object read-only, or make an array or tuple read-only |
|
Any type |
Make an immutable array of the given type |
|
Object types |
A map from a key type to a value type |
|
Object types |
Make all properties in an object required |
|
Function types |
A function’s return type |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access