angular - 无法在 Angular 5 的 tsconfig 中使用模块 esnext 进行动态模块导入
问题描述
我正在尝试在我的 angular 5 应用程序中进行动态导入。根据这个github issue,评论说 usingmodule: 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"
]
}
注意:没有es2016
in lib 会给我带来错误,因为我在代码中使用.find()
and .includes
on Array's。
编译时出现此错误
error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
不知道为什么当我有module: esnext
.
解决方案
我想通了。事实证明这是一个愚蠢的错误,我正在tsconfig.json
根文件夹中进行编辑,而文件夹中还有另一个tsconfig.app.json
覆盖src
了我的设置。
推荐阅读
- visual-studio-code - 如何在 VSCode 选择语言模式中删除 Django HTML 作为选项?
- c++ - 来自 dll 的对非成员运算符的未定义引用
- regex - Perl:正则表达式来剪切括号中的单词
- reactjs - React hooks:如何观察 JS 类对象的变化?
- python - 设备在 PyUSB 上不可用
- php - 如何将 PHP 变量调用到 HTML 元素中?
- python - 如何在 Cython(32 位)中使用(32 位)静态库中的符号
- scala - 使用 when 函数创建客户标尺
- flask - 具有多个外键的 Flask SQLAlchemy
- visual-studio - Code Lens 不显示最后编辑的人的姓名