具有TypeScript + Angular 2的量角器配置错误

时间:2016-07-22 14:41:07

标签: typescript angular protractor webpack

我在使用Protractor在我的项目中运行时遇到了问题。我的tsconfig.json文件有问题:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "noEmitHelpers": true,
    "baseUrl": "./src",
    "paths": {
      "components": ["app/components"],
      "core": ["app/core"],
      "data": ["app/data"],
      "pages": ["app/pages"],
      "schemas": ["app/schemas"],
      "utility": ["app/utility"]
    }
  },
  "exclude": [
    "node_modules"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": { "rewriteTsconfig": false }
}

它特别在“baseUrl”和“paths”选项上失败。如果我把它拿出去,那就完美了。有什么想法吗?

编辑: 我目前正在使用Protractor 3.2.2,我们更新到4.0只是为了得到这个堆栈跟踪:

TSError: ⨯ Unable to compile TypeScript
Unknown compiler option 'baseUrl'. (5023)
Unknown compiler option 'paths'. (5023)
    at Object.register (/Users/Dan/git/LifeSiteAngular2/node_modules/ts-node/src/index.ts:185:11)
    at Object.<anonymous> (/Users/Dan/git/LifeSiteAngular2/node_modules/ts-node/register.js:1:15)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/Users/Dan/git/LifeSiteAngular2/config/protractor.conf.js:5:1)
    at Module._compile (module.js:413:34)

1 个答案:

答案 0 :(得分:6)

问题是旧版本的typescript与tsconfig.json中的baseUrl和paths选项不兼容。

通过将量角器更新到版本4.0.0,将打字稿更新到版本2.0.0来修复此问题。