Re:Facebook Launches Flow, Static Type Checker for JavaScript
by masklinn on Tuesday November 18, 2014 @01:51PM
(#8625544)
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.
Re:Facebook Launches Flow, Static Type Checker for JavaScript
by Arnavion on Tuesday November 18, 2014 @01:53PM
(#8625558)
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.
Re:Facebook Launches Flow, Static Type Checker for JavaScript
by johnny_reilly on Wednesday November 19, 2014 @07:54AM
(#8629690)
Due to ship with TypeScript 1.4 - see recent blog post: http://blogs.msdn.com/b/typescript/archive/2014/11/18/what-s...
Re:Facebook Launches Flow, Static Type Checker for JavaScript
by DougBTX on Tuesday November 18, 2014 @01:56PM
(#8625579)
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.
Re:Facebook Launches Flow, Static Type Checker for JavaScript
by judah on Tuesday November 18, 2014 @01:46PM
(#8625504)
One major difference is the null checking. From what it looks like, they've added an additional type, "maybe", that represents a possibly-null object.
TypeScript doesn't have that concept, although it's been suggested by the community more than once.
Re:Facebook Launches Flow, Static Type Checker for JavaScript
by inglor on Tuesday November 18, 2014 @01:57PM
(#8625599)
Here is some interesting discussion on that aspect of the typesystem: https://github.com/Microsoft/TypeScript/issues/14 It also discusses Flow from 2 months ago (from a now removed video)
Re:Facebook Launches Flow, Static Type Checker for JavaScript
by avik on Tuesday November 18, 2014 @01:42PM
(#8625479)
No, instead of complaining about 'x' having the 'any' type, Flow will actually try to infer a static type for 'x'. So in the best case there would be no errors (and in the worst case there would be actual errors to fix).
Re:Facebook Launches Flow, Static Type Checker for JavaScript
by cwills on Tuesday November 18, 2014 @05:12PM
(#8626717)
Is there any reason we cannot use both TypeScript and Flow.
Besides perhaps the extra 'compile' time added to do both translation with TypeScript and then static analysis with Flow. Both tools have their advantages and disadvantages.
May as well throw in a linting tool as well..
[1]: http://flowtype.org