Last active
December 4, 2022 12:48
-
-
Save haggen/2184c58725aa2d7937b3cc5f8ae868de to your computer and use it in GitHub Desktop.
Extended TypeScript utility types.
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
/** | |
* Make all properties of T optional, except those in U. If exempt keys were already optional they'll stay optional. | |
*/ | |
type Semipartial<T, U extends keyof T> = Partial<T> & Pick<T, U>; | |
/** | |
* Make all properties of T required, except those in U. If exempt keys were already required they'll stay required. | |
*/ | |
type Semirequired<T, U extends keyof T> = Required<T> & Pick<T, U>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment