Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow doesn't resolve libdef's path correctly #5238

Closed
budarin opened this issue Nov 1, 2017 · 5 comments
Closed

Flow doesn't resolve libdef's path correctly #5238

budarin opened this issue Nov 1, 2017 · 5 comments

Comments

@budarin
Copy link

budarin commented Nov 1, 2017

I've installed flow-typed, have imported libdefs.
Import type from module:

import type { Store } from 'redux';

When I Ctrl+click on Store - WebStorm opens index.d.ts from /node_modules/redux/ folder while there present flow definition file /flow-typed/npm/redux_v3.x.x.js

If I import definition file directly

import type { Store } from '../../../../flow-typed/npm/redux_v3.x.x';

I got an error: Cannot resolve symbol 'Store' and clicking on Store does not open definition file at all.

.flowconfig

[ignore]
<PROJECT_ROOT>/.build/.*

[options]
include_warnings=true
suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore
# alias to flow folder
module.name_mapper='^flow/\(.*\)$' -> '<PROJECT_ROOT>/src/flow/\1'

[lints]
all=warn
untyped-type-import=error
sketchy-null=off

package.json

"eslint-plugin-flowtype": "^2.39.1",
"eslint-import-resolver-webpack": "^0.8.3", // for support aliases fom webpack
"eslint-plugin-import": "^2.8.0",
@jcready
Copy link
Contributor

jcready commented Nov 1, 2017

That's because redux_v3.x.x.js does not export any types. It's simply a libdef which defines a module named 'redux' which itself exports a type Store. Meaning the Store type is only able to be imported from 'redux'.

@budarin
Copy link
Author

budarin commented Nov 1, 2017

@jcready but flow does not recognize it ( - Flow: Cannot resolve symbol 'Store'

@jcready
Copy link
Contributor

jcready commented Nov 1, 2017

You need to change your import back to

import type { Store } from 'redux';

@budarin
Copy link
Author

budarin commented Nov 1, 2017

here another error in this case:
ESlint: Store not found in 'redux' (import/named)

Here are some reporters #830

@budarin
Copy link
Author

budarin commented Nov 2, 2017

I've found solution of the problem: eslint/import plugin scans node_modules and founds .ts files instead of reading definitions from flow-typed.
To solve the problem - add node_modules into ignore section of settings eslint/ignore
like here

@budarin budarin closed this as completed Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants