Skip to content

Types ​

Types: TypeScript utility types.

ExportWhat it does
AnyFunctionA type for any function, for generic constraints such as F extends AnyFunction (safer than Function, which also accepts classes and has an untyped call).
AwaitableA value that is returned directly or through a promise: the result of a callback that may be sync or async.
BrandA nominal type: a T that cannot be mixed up with another T of a different brand.
ConstructorA type for any class producing a T: mixins, dependency injection tokens, instanceof helpers.
DeepPartialMakes every property optional, at every depth: a patch of a nested settings object, read-only since a patch is only read.
DeepReadonlyMakes every property and array read-only, at every depth: a frozen configuration, a state snapshot that must not be changed in place.
ElementOfReads the item type of an array or tuple, such as the type of a const list of options.
EntriesThe [key, value] pairs of an object type, each key with its own value type: the precise type of Object.entries, which widens keys to string.
FirstParameterReads the type of the first parameter of a function, such as the event of a handler.
KeysOfTypeLists the keys of the properties whose type matches: the numeric fields of a record to chart, the boolean flags of a settings object.
LiteralUnionA union of known literals that still accepts any value of the base type, without losing autocompletion of the literals (a plain 'a' | 'b' | string collapses to string).
MergeCombines two object types, the properties of the second replacing those of the first (like an object spread { ...a, ...b }), where an intersection would give never for conflicting properties.
MutableRemoves readonly from the properties of a type, one level deep: a builder filling an object before handing it out as read-only.
NonEmptyArrayAn array with at least one item, so that its first item is never undefined.
NullableA T that may be null.
NullishA T that may be null or undefined.
OptionalA T that may be undefined.
PartialKeysMakes some properties optional: the input of a factory that fills them with defaults.
PickByTypeKeeps the properties whose type matches.
RequireKeysMakes some optional properties required: the result of filling in defaults.
SimplifyFlattens intersections and mapped types into a plain object type, so that editor tooltips show the properties instead of A & Omit<B, 'c'>.
UnionToIntersectionTurns a union into the intersection of its members: A | B gives A & B, to merge the types of a list of mixins or handlers.
ValueOfThe union of the value types of an object type, such as a const object used as an enum.

Generated from the JSDoc of the sources.