TypeScript编译中缺少index.ts.

问题描述 投票:0回答:1

运行'ng serve'时出现以下错误。

TypeScript编译中缺少node_modules / angular2-indexeddb / index.ts。请通过'files'或'include'属性确保它在您的tsconfig中。丢失的文件似乎是第三方库的一部分。已发布库中的TS文件通常是包装严重的库的标志。请在库存储库中打开一个问题,提醒其作者并要求他们使用Angular Package Format(https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview)打包库。

我想问题是angular2-indexeddb没有被tsconfig用于编译。 https://github.com/gilf/angular2-indexeddb

我认为应该通过在tslint.json中编辑以下配置来进行临时工作,但我需要一个解决方案来解决它。

  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ] 

是因为angular2-indexeddb不能提供良好的打包库吗?事实上,我不认为一个受欢迎的出版图书馆应该有这个问题。或者我错过了配置或编译的东西?我可以使用包编译工具/库将其编译为d.ts或spec.ts吗?

update:

实际上,我在目录中看到* .d.ts文件:

ls node_modules/angular2-indexeddb/
LICENSE                                 angular2-indexeddb.metadata.json        index.js
README.md                               angular2-indexeddb.min.js               index.js.map
angular2-indexeddb.d.ts                 angular2-indexeddb.min.js.map           index.ts
angular2-indexeddb.js                   angular2-indexeddb.ts                   package.json
angular2-indexeddb.js.map               index.d.ts

tsconfig.json中的内容:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}
angular typescript indexeddb tslint tsconfig
1个回答
4
投票
{
    "include": [
          "../src/**/*",
          "../node_modules/angular2-indexeddb/index.ts"
    ]
}

编辑:我建议你将你的lib更改为ngx-indexed-db,所以你不需要这样做。

© www.soinside.com 2019 - 2024. All rights reserved.