TypeScript Type Utilities

14 functions

Partial<T>Partial<T>

Constructs a type with all properties of T set to optional.

Required<T>Required<T>

Constructs a type consisting of all properties of T set to required.

Readonly<T>Readonly<T>

Constructs a type with all properties of T set to readonly.

Record<K, V>Record<K extends keyof any, V>

Constructs an object type whose property keys are K and whose property values are V.

Pick<T, K>Pick<T, K extends keyof T>

Constructs a type by picking the set of properties K from T.

Omit<T, K>Omit<T, K extends keyof T>

Constructs a type by picking all properties from T and then removing K.

Exclude<T, U>Exclude<T, U>

Constructs a type by excluding from T all union members that are assignable to U.

Extract<T, U>Extract<T, U>

Constructs a type by extracting from T all union members that are assignable to U.

NonNullable<T>NonNullable<T>

Constructs a type by excluding null and undefined from T.

ReturnType<T>ReturnType<T extends (...args: any) => any>

Constructs a type consisting of the return type of function T.

Parameters<T>Parameters<T extends (...args: any) => any>

Constructs a tuple type from the types used in the parameters of a function type T.

ConstructorParameters<T>ConstructorParameters<T extends abstract new (...args: any) => any>

Constructs a tuple type from the types of a constructor function type.

InstanceType<T>InstanceType<T extends abstract new (...args: any) => any>

Constructs a type consisting of the instance type of a constructor function type.

Awaited<T>Awaited<T>

Recursively unwraps the type wrapped inside Promise-like types.