I myself have never used flowtype before, but I’m considering trying to use it for Meteor packages/applications. Has anyone tried that? Does it work well?
And is it possible to support it through a meteor package? I can’t find any package doing that at the moment, but it would be nice if one can start using it simply by adding a package.
I am following FlowType too, but from what I see so far, it is a lot of work to start using Flow on a big project with a lot of dependencies, especially Meteor due to a couple of reasons:
You need to annotate a lot of code that is dynamically generated in run-time
Or you need to convert the TypeScript definitions
Typescript def conversion is not perfect(?)
Meteor’s Typescript defs are out of date
Since Meteor has a different loading scheme, one would need to fork flow-type and write support for Meteor’s loading in OCaml
I got FlowType working with 1.3. Like @rahul said, you can already use it because it’s in the ecmascript package. But there are a few thing that you need to add to your .flowconfig so that it will understand the absolute paths in 1.3 and the meteor packages imports. Like these:
// Absolute path
import {Todos} from '/lib/collections/Todos.js';
// Meteor core package
import {Meteor} from 'meteor/meteor';
// Other atmosphere packages
import {thing} from 'meteor/author:packagename';
You solve this by adding these options to your .flowconfig:
This is the best setup I’ve come up with so far and it prevents you from having to add all kinds of definition files. I would love to have some feedback on this to hear if this is working for everybody.
@jamiter, did you have any problems with node_modules? I’m very new to flow. I tried to integrate flow into one of my projects and got tons of errors from node_modules. I looked it up on SO and couldn’t wrap my head around the declarations stuffs. Any help would be greatly appreciated!
This comes down to mocking all node modules you use… Which is horrible in my opinion. It doesn’t let you use node_modules as a library. I mean: It should find them to check YOUR code, but it shouldn’t check the node_modules themselves.