r/typescript • u/theZozole • 19h ago
TypeScript utility for modeling variant-based types
dozsolti.github.ioSolves one specific problem: Handles complex types where two or more properties rely on each other.
For example, a Select component might support single (string) and multiple (string[]) selection, controlled and uncontrolled modes, and optional search or item creation.
The type for value depends on the selection mode, so does onChange(string), which need to be onChange(string[]) on multiple; while uncontrolled doesn't need onChange but defaultValue. Everything on the same type.
TypeFoundry lets you describe the variants and their relationships, then generates the resulting types.
It doesn't replace TypeScript's type system nor it's a runtime validation. It's pure typescript, meaning it creates no javascript.
It's to make complex type relationships easier to define and maintain.