Skip to content

Instantly share code, notes, and snippets.

@kofno
Created September 25, 2017 13:25
Show Gist options
  • Save kofno/d3402156cae7fc70dc86ac4c2ff38213 to your computer and use it in GitHub Desktop.
Save kofno/d3402156cae7fc70dc86ac4c2ff38213 to your computer and use it in GitHub Desktop.

Revisions

  1. kofno created this gist Sep 25, 2017.
    17 changes: 17 additions & 0 deletions example.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    // 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';