我正在尝试在我的 Angular 5 应用程序中进行动态导入。根据这个github issue ,评论说使用 module: esnext
应该可以让它工作。这是我的配置
"compilerOptions": {
"outDir": "./dist/out-tsc",
"noEmitOnError": true,
"target": "es2016",
"module": "esnext",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true,
"moduleResolution": "node",
"declaration": false,
"lib": [
"es2016",
"dom"
]
}
注意:在 lib 中没有 es2016
会给我错误,因为我在我的代码中对数组使用 .find()
和 .includes
.
编译时出现这个错误
error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
不确定为什么当我有 module: esnext
时它仍然说 targeting ECMA2015 modules。
最佳答案
我想通了。事实证明这是一个愚蠢的错误,我正在编辑根文件夹中的 tsconfig.json
而 src
中还有另一个 tsconfig.app.json
> 覆盖了我的设置的文件夹。
关于angular - 无法使动态模块导入与 Angular 5 中的 tsconfig 中的模块 esnext 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50525491/