Type alias MatchingSpecs<Output>

MatchingSpecs<Output>: Output extends SpecType
    ? TemplateExactMatch<Output>
    : Output extends Record<string, SpecType>
        ? {
            [K in keyof Output]: TemplateExactMatch<Output[K]>
        }
        : never

Infers (as type) the Specs required to generate output of a given type, represented as a SpecTypeOrDict. The inferred strings are based on the TemplateExactMatch part of the SpecValueTemplates for each SpecType.

Type Parameters

Example

const outputs = {
groceries: ['apples', 'bananas', 'oranges'],
unitPrices: [1.5, 2, 1],
total: 4.5,
isPaid: true,
notes: 'Buy organic if possible',
};

type TestSpecs = MatchingSpecs<typeof outputs>;
// expected:
// type TestSpecs = {
// groceries: "array of strings";
// unitPrices: "array of numbers";
// total: "number";
// isPaid: "boolean";
// notes: "string";
// };

Generated using TypeDoc