Export types in package.json
Is your feature request related to a problem? Please describe.
When installing @googlemaps/three and importing with typescript via import { ThreeJSOverlayView } from '@googlemaps/three';
I get an error Could not find a declaration file for module '@googlemaps/three'. '.../google-maps-webgl/node_modules/@googlemaps/three/dist/index.esm.js' implicitly has an 'any' type. There are types at '.../google-maps-webgl/node_modules/@googlemaps/three/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@googlemaps/three' library may need to update its package.json or typings.
Describe the solution you'd like
Export the dist/index.d.ts as well.
package.json before:
"main": "dist/index.umd.js",
"exports": {
".": {
"import": "./dist/index.esm.js",
"require": "./dist/index.umd.js",
"umd": "./dist/index.umd.js",
"browser": "./dist/index.esm.js",
}
},
"unpkg": "dist/index.min.js",
package.json after:
"main": "dist/index.umd.js",
"exports": {
".": {
"import": "./dist/index.esm.js",
"require": "./dist/index.umd.js",
"umd": "./dist/index.umd.js",
"browser": "./dist/index.esm.js",
"types": "./dist/index.d.ts"
}
},
"unpkg": "dist/index.min.js",
Describe alternatives you've considered
Making that change manually by editing the dependency inside my node_modules folder.
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.
@Krassnig Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:
- Check the issue tracker - bugs and feature requests for Google Maps Platform APIs and SDKs
- Open a support case - Get 1:1 support in Cloud Console.
- Discord - chat with other developers
- StackOverflow - use the
google-mapstag
This is an automated message, feel free to ignore.
Hi @Krassnig! Do you have an example-repo where this can be reproduced?
I think I saw that error before and it had something to do with the new moduleResolution: 'bundler' setting in the tsconfig, is that what you are using?
I think a problem with the proposed solution is that it's not clear which version of the package (umd or esm) the typings are for, but I will have a look into this.
Yes, I have set "moduleResolution": "bundler"
Here is a minimal reproduction of how I got the error: google-maps-imports.zip
Basically I just did a npm create vite and chose typescript.
Then installed @googlemaps/three and tried to import import { ThreeJSOverlayView } from '@googlemaps/three'; in src/main.ts