3 ms·
All fair points and totally valid. My concern is the facade/promise of type security.
by daviesgeek 9y ago
All fair points and totally valid.
My concern is the facade/promise of type security.
- rfw 9y agoForgive me if I misunderstand, I still don't understand your concern – TypeScript has type safety because it can check types at compile time (vs. JavaScript which has very limited type safety at run time). I don't think it's fair to call it a facade, because it is definitely commonly accepted as type safe.
- anderskaseorg 9y agoYour quarrel is not with JavaScript (as everyone else has pointed out, there’s no reason one can’t build a secure compile-time type system on top of JavaScript), but with some of the specific design decisions made by TypeScript that open soundness holes, such as “programmers are too stupid to understand the difference between covariance and contravariance, so we’ll pretend everything is bivariant”. See https://www.typescriptlang.org/docs/handbook/type-compatibility.html https://www.typescriptlang.org/docs/handbook/type-compatibil... for a less cynical presentation of these design decisions.
- nkohari 9y agoThis gives an explanation of why they made the choice: https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-function-parameters-bivariant https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-fun... Also, FWIW, in my experience, I don't think I've ever actually run into a problem with this in real code.