Last active
June 23, 2022 01:21
-
-
Save katsimoto/f5e3ee8a2c3a284effb2d9f1b8ccc045 to your computer and use it in GitHub Desktop.
TypeScript Tools
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
// https://medium.com/javascript-in-plain-english/powerful-typescript-tools-e1c7875fbb71 | |
type KeysToUnion<T> = keyof T; | |
type KeysToValue<T> = T[KeysToUnion<T>] | |
type KeysToTuple<T> = KeysToUnion<T>[] | |
type OmitPartial<T, K extends keyof T> = Omit<T, K> & { | |
[Key in K]?: T[Key] | |
} | |
type ReadonlyPartial<T> = { | |
readonly [K in keyof T]?: T[K] | |
} | |
type DeepReadonlyPartial<T> = { | |
readonly [K in keyof T]?: | |
T[K] extends object ? DeepReadonlyPartial<T[K]> : T[K] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment