Trying Flow on my node.js code…Let’s see how this goes
- google flow
- click “getflow.com”
- was something else
- google flow javascript
- found flowtype.org
- Click “get started” and landed here https://flowtype.org/docs/getting-started.html#_
First thoughts, okay this is for a new project, but I’m not making a new project, so adapting to my life. In this case we’ll try with my node.js project.
touch .flowconfig
npm install --save-dev flow-bin
- Add
// @flow
to my index.js file// seems gross to me, but doing it anyway
- Typing
npm run-script flow
thought maybe it would work, but it doesn’t. get “missing script: flow”
- Typing
./node_modules/.bin/flow
instead (not from docs) - lots of weird startup stuff…. “flow is still initializing”
- “Found 43 errors”
node_modules/findup/test/fixture/f/e/d/c/b/a/top.json:1
1:
^ Unexpected end of input
node_modules/findup/test/fixture/f/e/d/c/config.json:1
1:
^ Unexpected end of input
.... // goes on an on
Errors some pretty unrelated to anything I'm doing. Giving up.
- google the error messages
- Found facebook/flow#1420 (comment) trying it
- "Found 49 errors"
> 6 more errors than last time!!?!?
- Okay there's a not about the
main
field with that regex, trying another regex.*/node_modules/.*/\(lib\|test\).*\.json$
- "Found 36 errors"
> hey progress
- Let's look at the last two
node_modules/react/node_modules/fbjs/lib/Deferred.js.flow:60
60: Promise.prototype.done.apply(this._promise, arguments);
^^^^ property `done`. Property not found in
497: declare class Promise<+R> {
^ Promise. See lib: /private/tmp/flow/flowlib_22c9017e/core.js:497
node_modules/react/node_modules/fbjs/lib/shallowEqual.js.flow:29
29: return x !== 0 || 1 / (x: $FlowIssue) === 1 / (y: $FlowIssue);
- Seems like facebook is breaking flow. Pretty weird.
- Googling it.
- Found facebookarchive/draft-js#305
- @zpao says we need to update
fbjs
. I don't even use that dep directly, so I don't agree. - Getting annoyed again, but running
npm ls fbjs
p2pnodeweb@1.29.0 /Users/jamuferguson/dev/paypal/web
├─┬ flux@2.1.1
│ └─┬ fbemitter@2.0.2
│ └── fbjs@0.7.2
└─┬ react@15.3.1
└── fbjs@0.8.4
grep 'version":' ./node_modules/fbjs/package.json
"0.1.0-alpha.7"
- Hmm, seems old
npm i fbjs
grep 'version":' ./node_modules/fbjs/package.json
- "version": "0.8.4"
- seems better, let's
./node_modules/.bin/flow
- "Found 38 Errors"
> Okay ,that's 2 more than before" and more JSON errors in there
giving up again, for now
Now we're getting this error:
Which I assume means that while it knows about the vanilla node.js
req
it doens't know about express specific properties likereq.query
.