Created
July 7, 2021 21:21
-
-
Save saostad/93164cfad57648bc60a3180962e66fda to your computer and use it in GitHub Desktop.
typescript type required fields based on other fields
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
type a = { | |
c: "Hello"; | |
/** ggg */ | |
d: boolean; | |
e?: never; | |
} | { | |
c: "World"; | |
d?: never; | |
/** hhh */ | |
e: string; | |
} | |
const b: a = { | |
c: "Hello", | |
// e: "dddddd" | |
d: true, | |
} | |
const c: a = { | |
c: "World", | |
e: "dddddd" | |
// d: true, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment