4 ms·
From my perspective, the static type checking is more or less the same as TypeScript's `--noImplicitAny` option as the first example on flowtype [1] shows, the
by fdomig 12y ago
From my perspective, the static type checking is more or less the same as TypeScript's `--noImplicitAny` option as the first example on flowtype [1] shows, the same can be achieved with
tsc --noImplicitAny hello.tsc
which will result in
hello.ts(2,14): error TS7006: Parameter 'x' implicitly has an 'any' type.
I do not see much difference.
[1]: http://flowtype.org http://flowtype.org
- avik 12y agoNo, 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).
- judah 12y agoOne 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.
- inglor 12y agoHere is some interesting discussion on that aspect of the typesystem: https://github.com/Microsoft/TypeScript/issues/14 https://github.com/Microsoft/TypeScript/issues/14 It also discusses Flow from 2 months ago (from a now removed video)
- masklinn 12y agoTS 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.
- Arnavion 12y agoUnion 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.
- johnny_reilly 12y agoDue to ship with TypeScript 1.4 - see recent blog post: http://blogs.msdn.com/b/typescript/archive/2014/11/18/what-s-new-in-the-typescript-type-system.aspx http://blogs.msdn.com/b/typescript/archive/2014/11/18/what-s...
- DougBTX 12y agoYep, here's some related discussion: https://github.com/Microsoft/TypeScript/issues/185 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.
- cwills 12y agoIs 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..