googlemaps / js-api-loader

Load the Google Maps JavaScript API script dynamically.
Apache License 2.0
347 stars 64 forks source link

Could not find a declaration file #825

Closed jmeinlschmidt closed 7 months ago

jmeinlschmidt commented 7 months ago

Environment details

 Node   : 20.11.0
 OS     : darwin-arm64
 npm    : 10.2.4
@googlemaps/js-api-loader@1.16.3
@types/google.maps@3.55.3
typescript@5.3.3
@angular/google-maps@17.2.0

Using esbuild in Angular v17.2.1.

Steps to reproduce

This error fails a build while trying to import { Loader } from '@googlemaps/js-api-loader';

Stack trace

✘ [ERROR] TS7016: Could not find a declaration file for module '@googlemaps/js-api-loader'. '/Users/.../node_modules/@googlemaps/js-api-loader/dist/index.umd.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/googlemaps__js-api-loader` if it exists or add a new declaration (.d.ts) file containing `declare module '@googlemaps/js-api-loader';` [plugin angular-compiler]

    apps/.../google-maps.ts:2:23:
      2 │ import { Loader } from '@googlemaps/js-api-loader';
        ╵                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~

Watch mode enabled. Watching for file changes...

Thank you!

wangela commented 7 months ago

If you would like to upvote the priority of this issue, please comment below or react on the original post above with :+1: so we can see what is popular when we triage.

@jmeinlschmidt Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

jmeinlschmidt commented 7 months ago

This error seems to be a regression after upgrading from 1.16.2 to 1.16.3 probably introduced by https://github.com/googlemaps/js-api-loader/commit/3d221ea20ddfd766b454f8b20c98248efdc254d0 (cc @usefulthink)

bjornharvold commented 7 months ago

Yes, I am seeing this as well.

Example:

Could not find a declaration file for module '@googlemaps/js-api-loader'. '/Users/crash/git/monorepo-typescript/node_modules/@googlemaps/js-api-loader/dist/index.umd.js' implicitly has an 'any' type.
     Try `npm i --save-dev @types/googlemaps__js-api-loader` if it exists or add a new declaration (.d.ts) file containing `declare module '@googlemaps/js-api-loader';`

   12 import { Libraries } from '@googlemaps/js-api-loader';
cgarrovillo commented 7 months ago

For anyone having this problem with a dependency they use that uses this library as a dependency, we were able to work around it using the overrides NPM config https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides

A notable library is the react-wrapper library that uses this library https://github.com/googlemaps/react-wrapper/issues/782#issuecomment-1947557563

martincostello commented 7 months ago

This doesn't appear to have fixed the issue: https://github.com/martincostello/apple-fitness-workout-mapper/pull/1158

samuelcole commented 7 months ago

i still can't deploy 1.16.5:

build: ../../node_modules/@googlemaps/js-api-loader/dist/index.esm.js
build: Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (408:0)
usefulthink commented 7 months ago

@samuelcole can you open a new issue for this? Also please add some more information about which build tools you are using. I'm not seeing this error in my current test-setups.

wangela commented 7 months ago

@martincostello are you still seeing the issue if you upgrade to v1.16.5?

martincostello commented 7 months ago

Nope, now I get the same new error as mentioned above: https://github.com/martincostello/apple-fitness-workout-mapper/pull/1160

usefulthink commented 7 months ago

fix is incoming.

wangela commented 7 months ago

These fixes should now be available in v1.16.6. Please reopen if the error persists.