3 ms·
How is this different from using Facebook Flow? I have been using Flow on a JavaScript project, along with Babel for ES6, and enjoying the experience quite a lo
by haberman 11y ago
How is this different from using Facebook Flow? I have been using Flow on a JavaScript project, along with Babel for ES6, and enjoying the experience quite a lot.
- dietrichepp 11y agoTypescript is older (2012 vs 2014), more mature and stable (v1.7 vs v0.x), has better tooling support (autocompletion in Visual Studio), is easier to install (you only need NPM), has better documentation, and is easier to Google (try searching for "flow" online!). There are also plenty of common libraries with Typescript annotations, so you can just use e.g. Phaser and Typescript together without any extra work. Other than that Flow and Typescript are fairly similar. Perhaps someone who has used Flow can explain what makes it different from Typescript.
- strmpnk 11y agoFlow offers some interesting control over things like optional types (nullable) and intelligent understanding of type tests in conditionals or calls to libraries like invariant. I've had these sorts of features catch quite a few bugs in my editor before even running a single test. Flow is also based on a daemon which continuously monitors your code. As such, it incrementally checks your modules allowing it to be extremely fast once started. I ended up using flow since it fit with the language feature set I was using with Babel (JSX in react code being one example). Since then, I've grown to enjoy the flow based typing and the rather good support for optional and non-optional types. Looking at the code lately seems to show some interesting stuff in the pipeline too. Taint tracking seems like a very useful one that I'd love to implement and seems like a natural extension of the code-flow based type system. Flow could definitely use more documentation and more example code but I found the community on IRC extremely helpful and polite so perhaps it's not a bad time to start if you're willing to do a little reading on the site first: http://flowtype.org/docs/getting-started.html http://flowtype.org/docs/getting-started.html
- spion 11y agoTypeScript has type guards, which covers #1. Also has custom type guards, which lets you write your own checks that constrain union types. TypeScript also has a language services server which runs as a daemon, lets you submit incremental edits to it and supports services such as autocomplete, rename refactoring and pretty much anything you see in visual studio or visual studio code. But yes, the type system has a couple of unfortunate flaws that are relics from its beginnings (cant express non-nullable types).
- curveship 11y agoAlso worth noting is that Flow is Mac and Linux only, no Windows support. We're a mixed platform shop, so that excludes Flow.
- aikah 11y agoFlow doesn't run on Windows and isn't written in Javascript.
- Keats 11y agoWe compared Flow and Typescript for our projects, you can see the articles https://blog.wearewizards.io/flow-and-typescript-part-1-flow https://blog.wearewizards.io/flow-and-typescript-part-1-flow and https://blog.wearewizards.io/flow-and-typescript-part-2-typescript https://blog.wearewizards.io/flow-and-typescript-part-2-type... TL;DR: Flow inference is super nice but community and tooling is lacking compared to TypeScript imo so we ended up using TS
- mercer 11y agoThank you for the links. I've been looking into both and also ended up with TypeScript, but for no particular good reason. These articles are helpful!