[英]TS Error with `lodash-es` using ionic2, Typescript, RollupJs, es2015 modules
I'm using lodash
with the new ionic2@RC.0
project template, which includes 我在新的
ionic2@RC.0
项目模板中使用lodash
,其中包括
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. 但是显然,由于摇树,建议在
Rollup
使用lodash-es
。 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 我收到
Typescript
错误
error TS2307: Cannot find module 'lodash-es'.
However, the transpiled javascript
actually works and runs correctly. 但是,转译的
javascript
实际上可以正常运行。 What gives? 是什么赋予了?
here is my tsconfig
这是我的
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
}
}
问题是没有人为lodash-es创建类型文件,因此Typescript编译器无法验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.