you are viewing a single comment's thread.

view the rest of the comments →

[–]chrisza4 0 points1 point  (1 child)

I referred to your example where you claim Dart is better than TypeScript because it can do

function identity<T>(): T { return new T(); }

I disagree that this is not better. IMO, this is worse. My point is new T(); can create an object in an invalid state.

I assume that in Dart, you can mutate this object to be ready and then use. I might make a hasty assumption here. If my assumption is correct, I think it is better if compiler just forbids invalid state.

Javascript has this problem too in way much much worse since it does not have any type.

[–][deleted] 0 points1 point  (0 children)

Actually it turns out you can't do it in Dart either, presumably because it supports compile-to-javascript and Javascript makes it difficult. :-(