11 comments

  • mpoteat 2 minutes 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. It includes a suite of type-level parser combinator utilities as well and is built on higher-kinded type abstractions.

  • drej 19 minutes 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

  • johnfn 2 hours 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 an hour 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 2 hours 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."

  • dvt 33 minutes ago

    (removed)

    • kuruczgy 27 minutes ago

      TypeScript (the types part) absolutely does have ternary operators: https://www.typescriptlang.org/docs/handbook/2/conditional-t...

    • mpoteat 20 minutes 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 9 minutes 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

  • tmcanada 3 hours ago

    How does it compare to TypeBox?

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

    • cjonas 3 hours ago

      Pretty sure this is a joke/demo for the power of type scripts typing system