打字稿模块“无”和“CommonJS”之间的区别

时间:2017-08-21 18:18:17

标签: typescript

似乎将compilerOptions.module设置为NoneCommonJS的tsc用于生成相同的已转换代码。这两者有何不同?为什么有两个选项用于生成(显然)相同的转换代码?

1 个答案:

答案 0 :(得分:2)

module设置为None,我们无法使用导入,导出或模块扩充(@artem在以下注释中注明的方式除外。)< / p>

这是the source of the message

"Cannot use imports, exports, or module augmentations when '--module' is 'none'.": {
    "category": "Error",
    "code": 1148
},

如果module设置为CommonJS,如果我们选择不使用导入,导出或模块扩充,那么我们的输出可能与我们的输出看起来相同将module设置为None

相关问题