sam-goodwin / punchcard

Type-safe AWS infrastructure.
Apache License 2.0
507 stars 20 forks source link

add an `enum` type #19

Open sam-goodwin opened 5 years ago

sam-goodwin commented 5 years ago

It should be possible to create types that resemble enums.

E.g.

const type = enum('a', 'b'): // is of Type<'a' | 'b'>

Probably do with function overloading

function enum<A1 extends string>(a: A1): Enum<A1>
function enum<A1 extends string, A2 extends string>(a: A1, a2: A2): Enum<A1 | A2>
// etc.