VariantFamilySpec
On this page

VariantFamilySpec

Interface in Variants

What variantFamily is given.

import type { VariantFamilySpec } from 'typeshade'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

interface VariantFamilySpec<A extends Record<string, readonly unknown[]>> {
readonly axes: A;
readonly build: (axes: AxisValues<A>) => ModuleDecl;
readonly key: (axes: AxisValues<A>) => string;
}

Instance properties

axesread only A

The axes, each as the list of values the host can select.

buildread only (axes: AxisValues<A>) => ModuleDecl

Build the module for one point in the space. Ordinary TypeScript branching: read the axis values and construct only what this point needs, so the losing arm is never built.

keyread only (axes: AxisValues<A>) => string

The program’s identity. Must mention every axis build reads: two points that derive the same key would share one cache id while naming different programs, and variantFamily throws when that happens. Derive it from axes; a key written by hand is how an axis gets left out.

See also

Source

src/core/variant-family.ts, line 49, at commit 26de7be8

Edit this page Report a problem