Created
June 17, 2019 13:33
-
-
Save StJohn3D/1de124283dfd0dac39cc22a1cee2a841 to your computer and use it in GitHub Desktop.
Get subtype from an existing type/interface by omitting one or more properties.
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
/** | |
* Get subtype from an existing type/interface by omitting one or more properties. | |
* | |
* **Usage:** | |
* ```ts | |
* type TSubType = Omit<IOriginalType, 'Prop1' | 'Prop2'> // IOriginalType without Prop1 and Prop2 | |
* ``` | |
*/ | |
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Real credit for this belongs to a stack overflow answer I found somewhere a while ago but I don't remember where the link is. Anyway, I was tired of looking for this used in my projects so I decided to give it a proper place in git where I can easily find it again.