在 1.5.0-beta(目标:ES6)上出现错误 TS1204,但是,一切正常

Getting error TS1204 on 1.5.0-beta (target: ES6), however, everything works fine

看起来从 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 ]
}

错误说明了一切:

Cannot compile external modules into amd or commonjs when targeting es6 or higher.

ES6 内置了模块,所以从 tsconfig.json:

中删除这一行
"module": "commonjs",

然后因为你正在使用 babel 从 ES6 编译到 ES5,所以告诉它编译到 CommonJS:

 babel --modules common ...etc...