Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export types in package.json #837

Open
Krassnig opened this issue Sep 11, 2023 · 3 comments
Open

Export types in package.json #837

Krassnig opened this issue Sep 11, 2023 · 3 comments
Labels
type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@Krassnig
Copy link


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.

@Krassnig Krassnig added triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Sep 11, 2023
@wangela
Copy link
Member

wangela commented Sep 11, 2023

If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 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:

This is an automated message, feel free to ignore.

@usefulthink
Copy link
Contributor

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.

@usefulthink usefulthink added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Sep 11, 2023
@Krassnig
Copy link
Author

Krassnig commented Sep 11, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants