2 ms·
Sure, let me start with a disclaimer, I have used TS briefly and found it great but I personally prefer Elm's type system. My understanding is TS was designed
by aszen 6y ago
Sure, let me start with a disclaimer, I have used TS briefly and found it great but I personally prefer Elm's type system.
My understanding is TS was designed specifically to statically type existing JS patterns in popular libraries and frameworks and while that's great, newer libraries rarely need such flexibility if they aim for type safe designs from the start.
When I use typescript I often get the feeling there are multiple ways of typing the same function, which is reasonable given that one of TS goals was to embrace the JS ecosystem and that meant covering multiple overlapping use cases.
Consider Enums and Union types in TS, at a higer level both express the same thing (this value can be one of these sets of values) but in practice there is lots of discussion on when to use which.
I have not seen sum types (as they are usually called) being implemented in two different ways in other languages.
I think one of the ways to think about TS is that it was designed to help programmers better understand their JavaScript code by adding types while reinforcing their designs in a safe manner so if TS didn't have to interface with existing JS code many of the cool tricks it's picked up would not be useful I think.
Finally on the point of expressivity, I'm interested to know how TS helps in modelling application logic to make invalid state impossible.