javascript - Flow type checker errors in node_modules/* -
i've initialized flow project flow init
in fresh https://github.com/davezuko/react-redux-starter-kit project.
when flow check, finds several errors in node_modules. errors happening in /* flow */ annotated library files.
it looks this:
node_modules/editions/source/index.js:33 33: const {name, editions} = require(packagepath) ^^^^^^^^^^^^^^^^^^^^ parameter passed require() must literal string. node_modules/fbjs/lib/deferred.js.flow:60 60: promise.prototype.done.apply(this._promise, arguments); ^^^^ property `done`. property not found in 474: declare class promise<+r> { ^ promise. see lib: /private/tmp/flow/flowlib_d34ebcf/core.js:474 node_modules/fbjs/lib/shallowequal.js.flow:29 29: return x !== 0 || 1 / (x: $flowissue) === 1 / (y: $flowissue); ^^^^^^^^^^ identifier `$flowissue`. not resolve name
should make flow ignoring files? assume may affect type checking correctness.
both fbjs , editions written using flow. each have .flowconfig
files various configurations. errors seeing due .flowconfig
being configured differently.
the easiest fix modify .flowconfig
support things edition , fbjs using.
- adding
module.ignore_non_literal_requires=true
[options]
section should fix first error. default flow error if pass variablerequire()
, since flow wants understand dependency graph. option relaxes requirement. - adding
./node_modules/fbjs/flow/lib
[libs]
section should fix second error. fbjs uses non-standard version ofpromise
, ship library definition version ofpromise
. - adding
suppress_type=$flowissue
[options]
section should fix third error. option aliasesany
type$flowissue
. makes more clear when you're usingany
suppress error.
in future, flow team imagines flow users choose ignore node_modules/
altogether , instead rely on library definitions https://github.com/flowtype/flow-typed/, we're investing in definitions , tooling around flow-typed. avoid sort of situation you're running into.
Comments
Post a Comment