2

我想将包含以下代码的文件 tsconfig.json 添加到此处的 stackblitz 示例https://stackblitz.com/edit/angular-1tbbrn。请问有人做过这个有人做过吗??

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

1 回答 1

1

如果您查看在自己的文件系统上创建的 Angular 项目,您会发现如下条目angular.json

{
  "tsConfig": "tsconfig.app.json"
}

当您查看 tsconfig.app.json 时,您会看到如下内容:

{
  "extends": "./tsconfig.json", // <------ inheritance
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": []
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ],
  "exclude": [
    "src/test.ts",
    "src/**/*.spec.ts"
  ]
}

所以你可以看到它通过属性tsconfig.app.json继承。tsconfig.jsonextends

您已添加tsconfig.json到您的项目,但没有app.config.json,因此它没有被angular.json.

添加一个tsconfig.app.json继承的新文件tsconfig.json应该可以工作。

于 2020-02-25T08:43:59.430 回答