Last active
January 16, 2023 17:37
-
-
Save huozhi/5cd4697d9e46c3157430e63905056c14 to your computer and use it in GitHub Desktop.
typescript cheat sheet
This file contains hidden or 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 KeysOfUnion<T> = T extends T ? keyof T : never |
This file contains hidden or 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 Narrow<T> = T extends Function | |
? T | |
: never | T extends string | number | boolean | bigint | |
? T | |
: never | T extends [] | |
? [] | |
: never | { [K in keyof T]: Narrow<T[K]> } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment