diff --git a/lib/index.ts b/lib/index.ts index bbfe8c0..995283d 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -7,12 +7,14 @@ export type InternalConstructors = { value: Parameters[0] } name: R + definition: D } } export type Constructors = { [R in keyof D]: { (value: Parameters[0]): InternalInstance name: R + definition: D } } export type MatchOptions = { @@ -138,6 +140,9 @@ export function type( return { type, tag, value } } + api[tag].name = tag + api[tag].definition = definition + api[`is${tag}`] = (v: any) => v.tag === tag api[`get${tag}`] = (v: any, fallback: any, f: any) => { if (f) { @@ -151,6 +156,7 @@ export function type( api[`flatMap${tag}`] = (v: any, f: any) => { return v.tag === tag ? f(v.value) : v ?? null } + } return api }