扩展 tsconfig 时指定类型有什么意义?

What is the point in specifying types when extending tsconfig?

我有一个使用@types 和一些自定义类型的 angular 应用程序。出于某种原因,当我为该应用程序提供服务时,它可以正常工作,而当我 运行 我使用 ng test 进行测试时,它找不到自定义类型。我不明白为什么会这样,我不明白你应该如何管理扩展配置或者为什么你想要在服务和测试之间使用不同的类型。

这是我自动生成的配置:

tsconfig.json

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

tsconfig.app.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "allowSyntheticDefaultImports" : true,
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "types": []
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

tsconfig.spec.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "module": "commonjs"
  },
  "files": [
    "test.ts",
    "polyfills.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}

我尝试了很多不同的变体,但仍然不明白为什么它在服务上有效,但在测试中无效。我知道不指定类型数组意味着应该抓取所有类型?然而事实似乎恰恰相反。

如果有人能提供一些帮助,我将不胜感激。

错误不是由缺少类型引起的,而是由于缺少类型的全局函数引起的。