@sinclair/typebox
Version:
Json Schema Type Builder with Static Type Resolution for TypeScript
10 lines (9 loc) • 381 B
JavaScript
import { UnionEvaluated } from '../union/index.mjs';
import { Literal } from '../literal/index.mjs';
import { TemplateLiteralGenerate } from './generate.mjs';
/** Returns a Union from the given TemplateLiteral */
export function TemplateLiteralToUnion(schema) {
const R = TemplateLiteralGenerate(schema);
const L = R.map((S) => Literal(S));
return UnionEvaluated(L);
}