Skip to content

Instantly share code, notes, and snippets.

@AlexFrazer
Last active March 26, 2025 13:13
Show Gist options
  • Save AlexFrazer/b1f2f89bc15d445c5d39904382f32a24 to your computer and use it in GitHub Desktop.
Save AlexFrazer/b1f2f89bc15d445c5d39904382f32a24 to your computer and use it in GitHub Desktop.
TypeScript utility functions
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