看起来所有内容都从Typescript正确编译到ES6到ES5。但是,我不断收到以下错误。我无法弄清楚导致此错误的原因......
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
设定:
tsconfig.json:
{
"version": "1.5.0-beta",
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"emitDecoratorMetadata": true,
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true,
"sourceMap": true,
"outDir": "build"
},
"filesGlob": [
"./src/**/*.ts",
"./typings/**/*.ts",
"!./node_modules/**/*"
],
"files": [ redacted ]
}
答案 0 :(得分:1)
错误告诉所有:
在定位es6 或更高版本时,无法将外部模块编译为amd或 commonjs。
ES6内置了模块,因此请从NS != null
tsconfig.json
然后,既然您正在使用babel从ES6编译到ES5,请告诉它编译为CommonJS:
"module": "commonjs",