sam-goodwin / punchcard

Type-safe AWS infrastructure.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add an `enum` type

sam-goodwin opened this issue · comments

commented

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.