Hello there!
Background
I’ve started to work on Flow types for Meteor. I know about these TypeScript ones, but there’s one thing… These are shallow. Let’s take this code:
import {Mongo} from 'meteor/mongo';
const Collection = new Mongo.Collection('collection');
const transform = doc => ({_id: doc._id, fields: Object.keys(doc).length});
const docs = Collection.find({}, {transform}).fetch();
What is the type of notes? Well, according to current TS types, it’s the collection type (inferred or whatever). My goal is to provide complete types. Current state allows you to do this:
(docs: {|_id: string, fields: number|}[]);
And of course throws an error here:
docs.map(doc => doc.other);
Yep, it’s correctly typed!
Goal
Main goal is to type whole Meteor core packages, namely this directory and (finally!) make a pull request to flow-typed.
Status
Current version provides complete types for two medium-sized projects (you can see, which part of API are these two using, as the rest is not typed yet).
How can I try it?
Simply go here and clone it into your flow-typed directory.
How can I help?
- Drop it in your project.
- Fix something and/or type missing parts.
- Make a pull request.
It’s that simple!
Update 2018-01-10
Few people asked me, how do I work with Flow and Meteor. Here’s a .flowconfig working with both 1.5 and 1.6:
[ignore]
.*/.meteor/.*\.json
.*/.npm/.*\.json
[options]
module.name_mapper='^\/\(.*\)$' -> '<PROJECT_ROOT>/\1'
module.name_mapper='^meteor\/\(.*\):\(.*\)$' -> '<PROJECT_ROOT>/.meteor/local/build/programs/server/packages/\1_\2'
module.name_mapper='^meteor\/\(.*\):\(.*\)$' -> '<PROJECT_ROOT>/.meteor/local/build/programs/web.browser/packages/\1_\2'
module.name_mapper='^meteor\/\(.*\)$' -> '<PROJECT_ROOT>/.meteor/local/build/programs/server/packages/\1'
module.name_mapper='^meteor\/\(.*\)$' -> '<PROJECT_ROOT>/.meteor/local/build/programs/web.browser/packages/\1'
We ignore .json files from Meteor sources (.npm is a directory for bundled npm modules), because some of them contains comments.

