【发布时间】:2019-12-30 01:51:01
【问题描述】:
我正在 app.ts 文件中编写导入语句 import { PI } from './math/circle' 并在 circle.ts 文件中有一个常量 export const PI = 3.14 但通过执行运行程序tsc app.ts --outFile app.js 一直显示这个错误。
错误 TS6131:无法使用选项“outFile”编译模块,除非“--module”标志为“amd”或“system”。 1 导出常数 PI = 3.14
但根据docs 我正确导入。我也尝试将 "module": "commonjs" 更改为 "module": "amd"/"system" 然后重新加载 VSCode 窗口,但没有运气。我哪里错了?
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "amd",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictPropertyInitialization": false
},
"exclude": [
"node_modules"
]
}
PS:打字稿版本 3.5.3
【问题讨论】:
标签: typescript