Utility Types
Awaited
type Awaited<T> = T extends Promise<infer P>
? P extends Promise<any> ? Awaited<P> : P
: never
Partial
type Partial<T> = { [P in keyof T]? : T[P] }
Required
type Required<T> = { [P in keyof T]-? : T[P] }
Readonly
type Readonly<T> = { readonly [P in keyof T]: T[P] }
Record
type Record<K extends keyof any, T> = { [P in K]: T }
Pick
type Pick<T, K extends keyof T> = { [P in K]: T[P] }
Omit
type Omit<T, K extends keyof T> = { [P in Exclude<keyof T, K>]: T[P] }
Exclude
type Exclude<T, U> = T extends U ? never : T
Extract
type Extract<T, U> = T extends U ? T : never
Parameters
type Parameters<T> = T extends (...args: infer P) => any ? P : never
ReturnType
type ReturnType<T> = T extends (...args: any) => infer R ? R : never