Describe variant and their properties; it combines every valid choice into a discriminated union.
Refine existing types
Add common properties and extend existing object types while letting variant-specific types take precedence.
bash
npm install typefoundry
TypeFoundry is a compile-time TypeScript utility for APIs whose property types change with their configuration. It generates types only; it does not create runtime values or validate input.
TypeScript library authors — Define APIs where the type of one property depends on another.
Developers building configurable APIs — Model valid combinations of options without manually maintaining large unions.
Maintainers of complex configuration types — Express constraints between configuration options and eliminate invalid combinations.
Developers building state-dependent APIs — Represent different states and their associated properties in the type system.
TypeFoundry is most useful when an API has multiple variants, relationships between properties, and enough possible combinations that manually maintaining discriminated unions becomes difficult.