1. 14

  2. 5

    I wish there’d be an example of how is it actually useful. Because the only thing I can think of is mentioned at the end of the post:

    With this, we have one of the most important elements of type-level computation: the type-level function. Brace yourselves for type-level Turing-completeness abuses!

    And I don’t read it as a joke. “Abuses” seem to me the exact result one could expect from it.

    1. 4

      This is a good survey of honest-to-god useful things you can do with conditional types. Hell, I’ve even done some of them in my own code.

      I have no idea how these techniques compare to what type-level Haskellers do in practice or in theory (and agree the post would be better with some real-life motivating examples), but conditional types do have lots of uses in TS, even if you never use them directly.

      1. 2

        Thanks! This one set it straight for me.

      2. 3

        I’ve previously written of somewhat practical applications I found for conditional types. They’re kind of unreadable but at least all of the complexity stays behind the API barries.

        1. 1

          I was thinking the same thing after I read this article. Thank you for asking this question and thanks to the number of replies that clear up the use case for me.

          I have never heard of this concept, but it is interesting.

        2. 2

          I love abusing Typescript’s turing-completeness. The sad part is that much of the code you’ll write using it will have to be untyped because the compiler can’t verify that it actually works.