Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saostad/93164cfad57648bc60a3180962e66fda to your computer and use it in GitHub Desktop.
Save saostad/93164cfad57648bc60a3180962e66fda to your computer and use it in GitHub Desktop.
typescript type required fields based on other fields
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