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

Types exports are incorrect in package.json #312

Open
marcomuser opened this issue May 8, 2024 · 0 comments
Open

Types exports are incorrect in package.json #312

marcomuser opened this issue May 8, 2024 · 0 comments

Comments

@marcomuser
Copy link

marcomuser commented May 8, 2024

According to Are The Types Wrong the types for idb are not set up correctly. The main issue is that the exports property in package.json defines only one type for both the .cjs as well as the .js file:

"exports": {
    ".": {
      "types": "./build/index.d.ts",
      "module": "./build/index.js",
      "import": "./build/index.js",
      "default": "./build/index.cjs"
    },
  },

This is, however, not possible. It needs to export a separate type declaration file for each:

"exports": {
    ".": {
      "import": {
        "types": "./build/index.d.ts",
        "default": "./build/index.js",
      },
      "require": {
        "types": "./build/index.d.cts",
        "default": "./build/index.cjs"
      }
    },

Under moduleResolution "nodenext" or "node16" in a CJS project, this leads to an import which resolves to an ESM type declaration file, but a CommonJS JavaScript file.

For context, this PR fixed the same issue in the openapi-fetch package: openapi-ts/openapi-typescript#1360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant