With typescript, when importing reselect in my code with usual es6 import syntax
import {createSelector} from 'reselect';
The typescript compiler complains with cannot find module reselect (error TS2307)
Typescript version 2.0.3
tsconfig.json
{
"compilerOptions": {
"module": "es6",
"target": "es6",
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"jsx": "react"
},
"exclude": [
"node_modules",
".meteor"
]
}
"reselect": "^2.5.4" in dependencies in package.json
Code working fine, but TS is complaining.
No additionnal typings added.
Thank you.
The tsconfig is really helpful.
Excluding node_modules also prevents Typescript from finding the typings within node_modules/reselect. You can change the module resolution setting to fix this - just add "moduleResolution": "node" to compilerOptions.
This applies to any npm package with bundled declaration files, such as Immutable.js.
That makes sense, and i can confirm that it indeed resolves the problem.
Thank you !
We are having the same issue, but have not found a resolution. "moduleResolution": "node", was already in our tsconfig.json
Using: {
"@angular/core": "^4.0.0",
reselect": "^2.5.4",
}
I'm having the same issues, but only when webpack dev server (using Create React App with TS scripts) reloads, not on initial load.
see https://stackoverflow.com/a/52720674/1660584 - no-unused-variable tslint rule may be causing this.
Most helpful comment
I'm having the same issues, but only when webpack dev server (using Create React App with TS scripts) reloads, not on initial load.