Created
July 29, 2021 20:06
-
-
Save iAmWillShepherd/cf0a99a15dbe8361b5b120d791ed6aa2 to your computer and use it in GitHub Desktop.
Use the Omit utility type to create a new type with specific properties removed。
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
interface BaseType { | |
a: string | |
b: number | |
c: number[] | |
} | |
// Keys 'a' and 'b' will be removed | |
type SubsetType = Omit<BaseType, 'a' | 'b'> | |
const subset: SubsetType = { | |
c: [1, 2, 3] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment