Last active
March 26, 2025 13:13
-
-
Save AlexFrazer/b1f2f89bc15d445c5d39904382f32a24 to your computer and use it in GitHub Desktop.
TypeScript utility functions
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
export type PromiseValue<T> = T extends Promise<infer U> ? U : never; | |
export type WithRequiredKeys<T extends object, R extends keyof T> = { | |
[K in Exclude<keyof T, R>]+?: T[K]; | |
} & { | |
[K in R]-?: T[K] | |
} | |
export type RemoveIndex<T> = { | |
[K in keyof T as string extends K | |
? never | |
: number extends K | |
? never | |
: symbol extends K | |
? never | |
: K]: T[K]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment