A parser for TypeScript types, written in TypeScript types

50 todsacerdoti 15 8/4/2025, 2:12:58 AM github.com ↗

Comments (15)

johnfn · 4h 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 · 3h 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.
Tade0 · 1h ago
This. I regret every use of `infer`, save for one instance in which it actually helped, but it was a side project anyway.
bapak · 4h 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."
askonomm · 2h ago
There was even a guy who got Doom running entirely in TS types[0].

[0]: https://www.youtube.com/watch?v=0mCsluv5FXA

sorrythanks · 1h ago
that's funny, it motivates me to type `any`
drej · 2h ago
For those not familiar with this kind of computing challenges, I must link this wonderful video about TypeScript types running... DOOM. https://www.youtube.com/watch?v=0mCsluv5FXA
mpoteat · 2h ago
If folks are interested in this sort of thing, but want to play around with higher order building blocks, http://hkt.code.lol may be worth checking out.

In addition to type-level analogues of your normal Lodash-esque functions, it includes a suite of type-level parser combinator utilities and is built on higher-kinded type abstractions.

owebmaster · 32m ago
Typescript looks more and more like a cult
tmcanada · 5h ago
How does it compare to TypeBox?

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

cjonas · 5h ago
Pretty sure this is a joke/demo for the power of type scripts typing system
dvt · 2h ago
(removed)
kuruczgy · 2h ago
TypeScript (the types part) absolutely does have ternary operators: https://www.typescriptlang.org/docs/handbook/2/conditional-t...
mpoteat · 2h ago
I took a look at the source for the attached repository - the parser is in fact clearly written as a generic type. The presence of ?, :, and ... operators represent conditional types and tuple level destructuring respectively.

This is a very impressive project in my view - it's baffling that you would have the wherewithal to link the discussion you did but not realize the novelty here.

aprilthird2021 · 2h ago
I once went really deep into fancy, fun generic Typescript types (think the kind of type that can verify whether a string is written in "SpongebobMemecase" like "tHiS" vs "this"), and Typescript types can and do use ternary and rest operators