apollographql / datasource-rest

A caching data source for REST APIs
MIT License
39 stars 20 forks source link

Typescript project build failing due to missing type declarations #273

Closed keerthana-tw closed 1 year ago

keerthana-tw commented 1 year ago

The type declarations are not there for the lodash packages and when installed, build is failing with the following error:

node_modules/@apollo/datasource-rest/src/RESTDataSource.ts(11,23): error TS7016: Could not find a declaration file for module 'lodash.clonedeep'. '/home/runner/work/project/node_modules/lodash.clonedeep/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/lodash.clonedeep` if it exists or add a new declaration (.d.ts) file containing `declare module 'lodash.clonedeep';`

This had happened for isplainobject dependency as well and we had to install the types separately even though we do not use it in project. The type declarations and exports should ideally be the handled by the package itself and not cause users to install dependencies separately.

trevor-scheer commented 1 year ago

This seems like a tsconfig issue in your project. I can install this package and build without issues in a simple typescript project (and no need to install those types packages myself).

Can you provide a small reproduction? I'm going to close this issue since I genuinely don't think there's an issue with the package, but happy to continue helping here and reopen if we find there's actually a problem.