oneOf
Function: oneOf()
Section titled “Function: oneOf()”function oneOf<TagKey, Base, Branches, P>(opts): OneOfProducer<OneOfOut<TagKey, Base, Branches>, P> & object;Defined in: src/core/producer.ts:370
An honest discriminated union. base fields are parsed once; the first branch
whose when XPath exists is parsed and merged, with its literal tag written
under tagAs.
The output type is inferred: a discriminated union keyed on tagAs, each
member being the shared base fields plus that branch’s fields plus the
literal tag. Presence is honoured throughout (omit → optional key).
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
TagKey extends string | - |
Base extends Record<string, Producer<unknown, Presence>> | - |
Branches extends readonly BranchInput<string, Record<string, Producer<unknown, Presence>>>[] | - |
P extends Presence | "optional" |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts | object & BaseMeta |
Returns
Section titled “Returns”OneOfProducer<OneOfOut<TagKey, Base, Branches>, P> & object