Created
October 24, 2024 10:41
-
-
Save source-c/bbaec5862c63c47fbe3e87a81458ba5e to your computer and use it in GitHub Desktop.
Typescript Utility Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type OptionalTypeOrNull<T> = T | undefined | null; | |
type Nullish = undefined | null; | |
type Falsy = false | "" | 0 | 0n | Nullish; | |
type Truthy<T> = T extends Falsy ? never : T; | |
type AnyCollection = ArrayLike<unknown>; | |
type AnyObject = { [p: string]: AnyObject | AnyCollection | unknown }; | |
type Maybe<T> = T | Nullish; | |
type MaybePromise<T> = Promise<T> | T; | |
type Immutable<T> = { | |
readonly [K in keyof T]: Immutable<T[K]>; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment