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.

  1. adding module.ignore_non_literal_requires=true [options] section should fix first error. default flow error if pass variable require(), since flow wants understand dependency graph. option relaxes requirement.
  2. adding ./node_modules/fbjs/flow/lib [libs] section should fix second error. fbjs uses non-standard version of promise, ship library definition version of promise.
  3. adding suppress_type=$flowissue [options] section should fix third error. option aliases any type $flowissue. makes more clear when you're using any 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

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -