r/typescript • • 19h ago

TypeScript utility for modeling variant-based types

Thumbnail dozsolti.github.io
3 Upvotes

Solves 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.


r/typescript • • 10h ago

New educational, free, ad-free game for learning TypeScript memory model

0 Upvotes

I noticed that many students struggle with the question of "if I update this slot, field or variable, what else will change in my program".

I wrote a little puzzle game to help you build this intuition over time. It is very mobile friendly, so you can play it at a bus stop or during a commercial break or wherever. Puzzles scale in difficulty.

You can use it in Python, JavaScript or TypeScript modes.

http://prescod.github.io/memory-mapper-game

Please respond with changes you would like to see, or bug reports, or whatever. There is also an in-app feedback button.

There are no ads in the game or any monetization at all. This is not an ad for a product!