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

        • askonomm 2 hours ago

          There was even a guy who got Doom running entirely in TS types[0].

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

          • sorrythanks 2 hours ago

            that's funny, it motivates me to type `any`

          • drej 2 hours 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 2 hours 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 21 minutes ago

                Typescript looks more and more like a cult

                • tmcanada 5 hours ago

                  How does it compare to TypeBox?

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

                  • cjonas 5 hours ago

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

                  • dvt 3 hours ago

                    (removed)

                    • kuruczgy 2 hours ago

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

                      • mpoteat 2 hours 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 2 hours 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