Typebox Helpers
UnionOfString and more to come!
UnionOfString and more to come!
Create TypeBox union types from arrays with full type safety:
import { UnionOf } from '@hunterstack/typebox-helpers'
const Numbers = UnionOf([1, 2, 3, 4, 5])
// TUnion<[TLiteral<1>, TLiteral<2>, TLiteral<3>, TLiteral<4>, TLiteral<5>]>
const Mixed = UnionOf([1, 'red', true])
// TUnion<[TLiteral<1>, TLiteral<"red">, TLiteral<true>]>
Create TypeBox union types from string arrays with full type safety:
import { UnionOfString } from '@hunterstack/typebox-helpers'
const Colors = UnionOfString(['red', 'green', 'blue'])
// TUnion<[TLiteral<"red">, TLiteral<"green">, TLiteral<"blue">]>
npm install @hunterstack/typebox-helpers