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

Error with typescript and ESM #196

Open
ZachHaber opened this issue Aug 31, 2023 · 0 comments
Open

Error with typescript and ESM #196

ZachHaber opened this issue Aug 31, 2023 · 0 comments

Comments

@ZachHaber
Copy link

When working with moduleResolution: nodeNext, the type definitions are interpreted by typescript as being commonjs. It doesn't seem to register the existence of the module property in the package.json.

So, the easiest way to resolve this to make TS happy is to add the exports property to the package.json and output a separate .d.ts file for the esmodule output.

  "exports":{
    ".":{
      "import": {
        "types":"./dist/index.d.mts",
        "default":"./dist/index.esm.js"
      },
      "require":{
        "types":"./dist/index.d.ts",
        "default":"./dist/index.cjs.js"
      }
    }
  },
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