UNPKG

normul

Version:

Normul is a tiny TypeScript/JavaScript library for data normalization and transformation

19 lines (18 loc) 993 B
import type { ParseContext, Simplify } from '../../types.js'; import { Schema } from '../Schema.js'; import { ObjectSchema, type ExtractShape, type Shape } from './ObjectSchema.js'; type InferUnion<T extends Schema[]> = Simplify<T[number] extends Schema<infer U> ? U : never>; export declare class UnionSchema<T extends [Schema, ...Schema[]]> extends Schema<InferUnion<T>> { protected readonly schemas: T; constructor(schemas: T); protected _normalize(input: unknown, ctx: ParseContext): InferUnion<T>; protected cloneArgs(): unknown[]; } export declare class DiscriminatedUnionSchema<T extends [ObjectSchema<Shape>, ...ObjectSchema<Shape>[]], D extends Extract<keyof ExtractShape<T[number]>, string>> extends UnionSchema<T> { protected readonly discriminator: D; protected readonly schemas: T; constructor(discriminator: D, schemas: T); protected _normalize(input: unknown, ctx: ParseContext): InferUnion<T>; protected cloneArgs(): unknown[]; } export {};