Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

TS bolts on a straightforward nominative type system without type unions (or non-nullable types), so it can't handle a variable typed as `number | string`, it'll immediately drop down to `any`. That is, flow aims to remain useful in the face of more JS idioms. It won't make a difference between nullable and non-nullable either, so AFAIK

    function length(x) {
      return x.length;
    }

    length(null);
can never be a compile-time error in typescript.


Union types are present in the master branch of the TS compiler. The compiler also uses instanceof and typeof === ... to reduce the range of types inside a branch, similar to Flow.


Due to ship with TypeScript 1.4 - see recent blog post: http://blogs.msdn.com/b/typescript/archive/2014/11/18/what-s...


Yep, here's some related discussion: https://github.com/Microsoft/TypeScript/issues/185

tl;dr: they want to support both of those features, the question is what syntax to use and how to introduce those features into the existing ecosystem.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: