4 ms·
Typescript (even with all those options on) isn't even close to sound. Some of the soundness issues are by design (making directly overlayed JS code reasonable
by tekacs 9y ago
Typescript (even with all those options on) isn't even close to sound.
Some of the soundness issues are by design (making directly overlayed JS code reasonable to type/interface with), some are due to 'taking too much time/design complexity if implemented'.
I won't go into them one by one, but you can jump into most of the issues here to get a sense:
https://github.com/Microsoft/TypeScript/issues?utf8=&q=Soundness https://github.com/Microsoft/TypeScript/issues?utf8=&q=Sound...
https://github.com/Microsoft/TypeScript/issues?utf8=&q=unsound https://github.com/Microsoft/TypeScript/issues?utf8=&q=unsou...
I won't take a position on the matter other than to say that it's a tricky balance and the TS team are at the very least extremely clear in saying that you should not be looking for a high degree of soundness here (JS interop is a higher priority).
If those things are important, I would recommend Scala.js or PureScript or... anything more self contained (and remember that they're still ultimately dynamically typed on the JS boundary, just not inside the language).
Here's the TS team explaining their position themselves:
https://github.com/Microsoft/TypeScript/issues/9825#issuecomment-233843817 https://github.com/Microsoft/TypeScript/issues/9825#issuecom...
https://github.com/Microsoft/TypeScript/issues/13003 https://github.com/Microsoft/TypeScript/issues/13003 (not the most cordial commenter unfortunately)
- boubiyeah 9y agoOh I know! You also can't control variance and it can display bad behaviors once in a while. Overall though, getting bitten by the unsoundness is fairly rare , imo.
- tekacs 9y agoWhen I started using Typescript (whilst at the time using Scala, Clojure and Python day to day), I ran into soundness issues constantly (daily). I think I wrote a lot of code assuming that the type checker was sound and could check my abstractions, only to find that it wasn't and it couldn't. If it were more sound, I would rely on the language to do more checking. I don't get bitten as much any more, but I'm pretty sure that's mostly because I know what tradeoffs the language is making and I use other mechanisms to ensure safety.