I'm using lodash with the new [email protected] project template, which includes
- Typescript
- Rollup
- es2015 modules
This works for me:
npm install lodash --save
npm install @types/lodash --save-dev --save-exact
// typescript
import _ from "lodash";
But apparently lodash-es is recommended with Rollup because of the tree-shaking thing. But when I do this:
npm install lodash-es --save // instead of `lodash`
npm install @types/lodash --save-dev --save-exact
// typescript
import _ from "lodash-es";
I get a Typescript error
error TS2307: Cannot find module 'lodash-es'.
However, the transpiled javascript actually works and runs correctly. What gives?
here is my tsconfig
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"pretty": true,
"target": "es5"
},
"filesGlob": [
"**/*.ts",
"!node_modules/**/*"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}