Skip to content
New issue

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

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

Already on GitHub? # to your account

The package types are not correctly exported #1155

Open
ptazithos opened this issue Jan 7, 2025 · 0 comments · May be fixed by #1156
Open

The package types are not correctly exported #1155

ptazithos opened this issue Jan 7, 2025 · 0 comments · May be fixed by #1156
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@ptazithos
Copy link

Hello,

The package "@googlemaps/maps" doesn't come with types in my project.
I noticed that the correct type file is located at "dist/index.d.ts", but somehow my editor cannot correctly apply it.

image

My project is created by rsbuild.

pnpm create rsbuild@latest

And the generated tsconfig is as follows:

{
  "compilerOptions": {
    "lib": ["DOM", "ES2020"],
    "jsx": "react-jsx",
    "target": "ES2020",
    "noEmit": true,
    "skipLibCheck": true,
    "useDefineForClassFields": true,

    /* modules */
    "module": "ESNext",
    "isolatedModules": true,
    "resolveJsonModule": true,
    "moduleResolution": "Bundler",
    "allowImportingTsExtensions": true,

    /* type checking */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true
  },
  "include": ["src"]
}

I found this can be fixed by appending explicit types to the package.json of "@googlemaps/maps"

{
  "exports": {
    ".": {
+     "types": "./dist/index.d.ts",
      "import": "./dist/index.esm.js",
      "require": "./dist/index.umd.js",
      "umd": "./dist/index.umd.js",
      "browser": "./dist/index.esm.js"
    }
  },
}
@ptazithos ptazithos added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 7, 2025
@ptazithos ptazithos linked a pull request Jan 7, 2025 that will close this issue
4 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant