// structural pattern with a discriminated-union static claim
const AmountShape = harden({
brand: BrandShape,
value: AmountValueShape,
});
// The structural inference would yield the cross-product
// `{ brand: Brand, value: NatValue | SetValue | ... }`. The cast
// unifies brand and value through the discriminated union.
export const AmountPattern =
({brand: BrandShape, value: AmountValueShape});
A pattern carrying an unchecked static type assertion. The runtime pattern still validates the structural shape it always did; the
Tparameter is a developer claim that values matched by this pattern inhabitT— typically narrower than what the structural shape can recover (e.g., a discriminated union, a branded type, or a template literal).Like a TypeScript
ascast,CastedPattern<T>is trusted by the type system but unverifiable at runtime. If the pattern matches a value that doesn't actually satisfyT, downstream code may misbehave with no runtime error.TypeFromPattern<CastedPattern<T>>resolves toT, bypassing the normal structural inference.