Created
September 13, 2022 10:45
-
-
Save JDMathew/54c5e061feaf97af29922ea6539a7ae7 to your computer and use it in GitHub Desktop.
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
export type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never; | |
export type $Omit<T, K> = Pick<T, Exclude<keyof T, K>>; | |
export type $RemoveChildren<T extends React.ComponentType> = $Omit< | |
React.ComponentPropsWithoutRef<T>, | |
'children' | |
>; | |
export type WithPartial<T, K extends keyof T> = Omit<T, K> & | |
Partial<Pick<T, K>>; | |
export type RequireOnly<T, K extends keyof T> = Partial<T> & | |
Required<Pick<T, K>>; | |
export type GetRequiredKeys<T> = { | |
[K in keyof T as undefined extends T[K] ? never : K]: T[K]; | |
}; | |
export type GetOptionalKeys<T> = { | |
[K in keyof T as undefined extends T[K] ? K : never]: T[K]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment