【问题标题】:How to configure tsconfig.json file to include .ts files of an angular library project?如何配置 tsconfig.json 文件以包含 Angular 库项目的 .ts 文件?
【发布时间】:2020-06-05 06:35:06
【问题描述】:

我创建了一个 Angular 8 库项目!这是一个带有 bootstrap 4 的简单数据表。现在我面临一些问题。当我在一个新项目中通过 npm 安装时,编译失败并出现错误,告诉我一些文件丢失,如下所示:

错误:TypeScript 编译中缺少 /home/atheodosiou/Documents/development/kino-statistics/node_modules/ng-bootstrap-table/src/lib/directives/b-body.directive.ts。请通过 'files' 或 'include' 属性确保它在您的 tsconfig 中。

我的库的 tsconfig.json 文件如下(我已经读过,如果我没有指定包含属性的文件,编译器将包含所有 .ts 文件):

    {
  "extends": "../../tsconfig.json",
  "compileOnSave": true,
  "compilerOptions": {
    "outDir": "docs/",
    "target": "es2015",
    "declaration": true,
    "inlineSources": true,
    "types": [],
    "lib": [
      "dom",
      "es2018"
    ],
    "noEmitOnError": true
  },
  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableResourceInlining": true
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

我尝试通过 include 属性包含所有这些,并通过 files 属性(不是同时)声明它们。

我做错了什么?

提前谢谢你!

【问题讨论】:

    标签: angular build tsconfig angular-library


    【解决方案1】:

    我看到包含的所有文件的方式是有

    "include": ["**/*.ts"]
    

    我相信您的排除语句仍应排除您请求的文件。

    【讨论】:

      猜你喜欢
      • 2017-11-11
      • 1970-01-01
      • 2022-12-21
      • 1970-01-01
      • 2019-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-29
      相关资源
      最近更新 更多