Skip to content

Instantly share code, notes, and snippets.

@kofno
Created September 25, 2017 13:25
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 kofno/d3402156cae7fc70dc86ac4c2ff38213 to your computer and use it in GitHub Desktop.
Save kofno/d3402156cae7fc70dc86ac4c2ff38213 to your computer and use it in GitHub Desktop.
Question about discriminated unions
// Given this
interface One {
kind: 'one';
value: 1;
}
interface Two {
kind: 'two';
value: 2;
}
// ... and this alias
type Number = One | Two;
// ... can the `kind` values be expressed as a type without having to explicitly do this:
type NumberKinds = 'one' | 'two';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment