Last active
April 18, 2023 12:27
-
-
Save devgioele/de1e6776dfe5ec2b6333e09c28667cc1 to your computer and use it in GitHub Desktop.
Partial and Required helpers
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
/** | |
* A version of `Partial` that makes only the given keys of `T` optional. | |
*/ | |
export type PartialPick<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>> | |
/** | |
* A version of `Partial` that makes all the not specified keys of `T` optional. | |
*/ | |
export type PartialOmit<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>> | |
/** | |
* A version of `Required` that makes only the given keys of `T` required. | |
*/ | |
export type RequiredPick<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>> | |
/** | |
* A version of `Required` that makes all the not specified keys of `T` required. | |
*/ | |
export type RequiredOmit<T, K extends keyof T> = Pick<T, K> & Required<Omit<T, K>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment