Hacker News new | ask | show | jobs
by samwgoldman 4052 days ago
TypeScript is great, but you might look again at flow. ES6 features are being added (I'm adding let/const support) and many already exist. Import/export (incl. types) are in, fat arrow syntax, destructuring, shorthand syntax for objects.

I get the most value of Flow through statically typed React component props, which is usable today with both `React.createClass`-style and `React.Component`-style components.

In my experience, Flow will infer much more about "plainly" written JavaScript than TypeScript, which will fall back to `any` unless code is annotated.

A small example, function types are contravariant in the negative position in Flow, but bivariant in TS—much weaker!

TLDR, if you haven't looked at Flow recently, look again!

3 comments

Really like the idea of Flow but doesn't look like IDE support is there yet? This is the killer feature of types in Javascript for me - not sure I'd adopt it until then.
There are some packages that provide support for flow in atom editor, like: https://atom.io/packages/ide-flow

I've been testing atom for front-end development in the last few days and it's pretty good, definitely worth checking out (I'm saying this as a vim-lover)

Atom with eslint, the react plugin and eslint-babel is just amazing for ES6/7 and React development. It's so much faster than it used to be, it's actually amazing.
For sure, tooling is an area that will get better over time. I am quite happy with the very simple vim-flow, but TypeScript's tooling and overall ecosystem (tsd/definitelytyped) is a lot more mature.
I will. By the way, I always use TS with --noImplicitAny, and the number of type annotations I've had to add is rather small and very reasonable (mostly just on function arguments of methods and non-lambda functions).

Seems like the flow docs may need an update to reflect the newest additions.

Thanks for contributing to Flow!