AngularCLI ng测试无法找到名称XY

时间:2018-01-26 21:07:12

标签: angular-cli angular5

我无法弄清楚在执行Cannot find name '...'时如何解决多个ng test错误。似乎所有组件(与其位置无关)都无法识别。

我的配置文件如下所示:

ts.config.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

tsconfig.spec.json

{
  "compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2017",
      "dom"
    ],
    "outDir": "../out-tsc/spec",
    "module": "commonjs",
    "target": "es5",
    "baseUrl": "",
    "types": [
      "jasmine",
      "node"
    ]
  },
  "files": [
    "test.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}
  • Angular CLI: 1.6.6
  • Node: 8.9.4

我已经尝试了此thread中提到的设置。

具体错误消息:

ERROR in /src/app/shared/service.ts (112,17): Cannot find name 'IUser'.

目前,单元测试只是由angular-cli自动生成的单元测试。

0 个答案:

没有答案