@metreeca/qest - v0.12.0
    Preparing search index...

    Type Alias Union<T>

    Union: { readonly [branch: `${number}`]: T }

    Union-typed property template.

    Requests a union-typed property one branch at a time, so alternatives that need different shapes can each state their own. Keys are opaque Branch labels telling the alternatives apart; which variants a branch retrieves is fixed by matching its shape against the property's declared variants, never by its key, so reordering or renaming variants at the source leaves an existing template valid. A variant left unmatched by every branch contributes no values, and a branch matching no variant is unsatisfiable and is rejected.

    const template: Template = {
    creator: {
    "0": { name: {} }, // a person-shaped variant
    "1": { legalName: {} } // an organisation-shaped variant
    }
    };

    A branch holds one value, never a collection: cardinality belongs to the property as a whole, and the Criteria constraining it ride on the entry hosting the union. A branch never holds another union directly, though a branch Template may carry unions of its own.

    Important

    A union MUST include at least one branch: the empty object {} is an Atomic. The type admits it only because TypeScript cannot express a non-empty index signature; isUnion rejects it at runtime.

    See Union for the design rationale.

    Type Parameters

    Type Declaration

    • readonly [branch: `${number}`]: T