Closed mwalkerwells closed 7 years ago
I couldn't figure out a way to tell Flow not to actually type check the library, yet still get the type definitions on module import. Removing the .flowconfig file was the way I accomplished this.
There is the new "flow gen-flow-files": https://github.com/facebook/flow/releases/tag/v0.32.0
Being this repo experimental I didn't put much love in the distribution problem so far. I guess it's time to publish a first release.
Here's my plan:
src
dirlib
dirlib
with the .flow suffix appended to the filename (named "shadow files", see https://github.com/facebook/flow/issues/1996 for context)flow-static-land/lib/<thing>
seems a bit verbose as import)0.1.0
version on npmThen, as usual, one can install flow-static-land
with npm install flow-static-land --save
and use it like this
// @flow
import * as arr from 'flow-static-land/lib/Arr' // <= note the /lib here
arr.map(n => n * 2, arr.inj(['a'])) // <= error
My 2 cents re: module imports:
import { Monad, Monoid, Functor } from './flow-static-land';
That would be handy but it means you end up importing all the modules, even those which you don't actually use in your app.
Another option, which seems more flexible, is to define your own prelude. So instead of:
// app.js
import * as arr from 'flow-static-land/lib/Arr'
import * as maybe from 'flow-static-land/lib/Maybe'
import * as tuple from 'flow-static-land/lib/Tuple'
// your code here
you first define a prelude.js
containing only the relevant modules for your app and then you just import the prelude
// prelude.js
import type { Arr } from 'flow-static-land/lib/Arr'
import type { Maybe } from 'flow-static-land/lib/Maybe'
import type { Tuple } from 'flow-static-land/lib/Tuple'
import * as arr from 'flow-static-land/lib/Arr'
import * as maybe from 'flow-static-land/lib/Maybe'
import * as tuple from 'flow-static-land/lib/Tuple'
export type {
Arr,
Maybe,
Tuple
}
export {
arr,
maybe,
tuple
}
// app.js
import { arr, maybe, tuple } from './prelude'
// your code here
Published a first version on npm (https://github.com/gcanti/flow-static-land/releases/tag/0.1.0)
Not sure what the fix is (other than removing the .flowconfig file on a build step), but wanted to bring this to your attention.
Flow 0.32.0
Error:
Files: test.zip
Read up on something similar here: https://github.com/facebook/flow/issues/1891
Before removing .flowconfig in /node_modules/flow-static-land/
After removing .flowconfig in /node_modules/flow-static-land/