使用 Angular 2,我在 Chrome 控制台中收到警告:
TypeScript [Warning] transpiling to CommonJS, consider setting module: "system" in typescriptOptions to transpile directly to System.register format
我已经彻底搜索了网络,但找不到有关此问题的解决方案或文章。
我确实找到了this网站,提到使用:
--allowSyntheticDefaultImports (boolean)
作为
module === "system"
我添加到我的 tsconfig.json
文件中:
{
"compilerOptions": {
"target": "es5",
//"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noEmitHelpers": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"allowSyntheticDefaultImports": true,
"module": "system"
}
}
但这并没有帮助。
有什么建议吗?
最佳答案
您可以通过设置 tsconfig.json
选项的 compilerOptions
来将 module
设置为 system
选项。
tsconfig.json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "system",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true
}
}
您还可以通过命令行执行相同的操作,方法是在命令参数中添加 --module system
。
关于angular - TypeScript [警告] 转换为 CommonJS,考虑设置模块 : "system" in typescript Options,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42392288/