A parser for TypeScript types, written in TypeScript types

30 todsacerdoti 7 8/4/2025, 2:12:58 AM github.com ↗

Comments (7)

dvt · 8m ago
This parser is not written in TS types, and this kind of pedantry (especially when claiming "no js here!") is important. In fact, the parser includes many uses of both the ternary operator as well as the rest operator, both of which are absolutely not part of the type system and are most certainly part of JS.

While this tries to reach the levels of "TypeScript is Turing complete[1]" (which happens to be super cool), it is, in my humble opinion, not even remotely as interesting.

[1] https://github.com/Microsoft/TypeScript/issues/14833

kuruczgy · 2m ago
TypeScript (the types part) absolutely does have ternary operators: https://www.typescriptlang.org/docs/handbook/2/conditional-t...
johnfn · 1h ago
Sometimes at work I can't figure out some TS type and start thinking it's impossible. Then I remember that repos like this exist, and if some guy really managed to parse Typescript types in Typescript, that my problem is peanuts compared to that.

That usually motivates me to solve my problem.

Etheryte · 35m ago
On the flip side, if you can't find a close enough type definition with reasonable effort, it's often a sign that you're about to enter gibberish type territory and it might be time to reconsider. Even if a type does exist in the end, it might be unparseable to every human on your team, future you included.
bapak · 1h ago
Some things are still impossible. I lost count of the bugs I reported to TS only to be told that "works as intended" or that it's a "design limitation."
tmcanada · 2h ago
How does it compare to TypeBox?

https://github.com/sinclairzx81/typebox#syntax

cjonas · 2h ago
Pretty sure this is a joke/demo for the power of type scripts typing system