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

Closed
ZachHaber opened this issue Aug 31, 2023 · 1 comment · Fixed by #201
Closed

Error with typescript and ESM #196

ZachHaber opened this issue Aug 31, 2023 · 1 comment · Fixed by #201

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"
      }
    }
  },
@AntonioVdlC
Copy link
Owner

Thanks for raising this issue, and sorry it took so long for me to have a look at this!

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

Successfully merging a pull request may close this issue.

2 participants