TypeScript 编译中缺少 index.ts

index.ts is missing from the TypeScript compilation

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

node_modules/angular2-indexeddb/index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the 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没有提供好的封装库?事实上,我认为一个流行的出版图书馆不应该有这个问题。或者我错过了一些配置或编译的东西?我可以使用包编译 tools/library 将其编译成 d.ts 或 spec.ts 吗?

更新:

其实我在目录中看到了*.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"
    ]
  }
}
{
    "include": [
          "../src/**/*",
          "../node_modules/angular2-indexeddb/index.ts"
    ]
}

编辑:我建议您将您的库更改为 ngx-indexed-db,这样您就不需要这样做了。