将编译器选项添加到 stackblitz 项目

Adding compiler options to a stackblitz project

我想将包含以下代码的文件 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"
    ]
  }
}

如果您查看在自己的文件系统上创建的 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 通过 extends 属性继承自 tsconfig.json

您已将 tsconfig.json 添加到您的项目,但未添加 app.config.json,因此 angular.json 未引用它。

添加继承 tsconfig.json 的新文件 tsconfig.app.json 应该可行。