- discriminator<const D, const M>(discriminator, mapping): CompiledSchema<{
[K in keyof M]: M[K] extends CompiledSchema<infer P, unknown>
? {
[Y in keyof (Record<D, K> & P)]: (P & Record<D, K>)[Y]
}
: never
}[keyof M], {
discriminator: D;
mapping: {
-readonly [K in keyof M]: M[K] extends CompiledSchema<unknown, infer S>
? S
: never
};
}> Type Parameters
- const D extends string
- const M extends Record<string, CompiledSchema<Record<string, unknown>, unknown>>
Parameters
- discriminator: D
- mapping: M
Returns CompiledSchema<{
[K in keyof M]: M[K] extends CompiledSchema<infer P, unknown>
? {
[Y in keyof (Record<D, K> & P)]: (P & Record<D, K>)[Y]
}
: never
}[keyof M], {
discriminator: D;
mapping: {
-readonly [K in keyof M]: M[K] extends CompiledSchema<unknown, infer S>
? S
: never
};
}>
a schema that accepts discriminated unions