Augie Li
Augie Li

Reputation: 318

index.ts is missing from the TypeScript compilation

I got following error when running '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).

I guess the issue is that angular2-indexeddb is not taken into compilation by tsconfig. https://github.com/gilf/angular2-indexeddb

I think there should be a temporary work around by editting the following configuration in tslint.json, but I need a solution to work through it.

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

Is it because angular2-indexeddb doesn't provide a good packaged library? In fact, I don't think a popular published library should have this issue. Or I missed something for configuration or compilation? Can I use package compilation tools/library to compile it into d.ts or spec.ts?

update:

In fact, I see *.d.ts file in the directory:

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

Content in 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"
    ]
  }
}

Upvotes: 2

Views: 13562

Answers (1)

Charles Assuncao
Charles Assuncao

Reputation: 568

{
    "include": [
          "../src/**/*",
          "../node_modules/angular2-indexeddb/index.ts"
    ]
}

EDIT: I do recommend you change your lib to ngx-indexed-db, so you don't need to do this.

Upvotes: 5

Related Questions