Skip to content

Conversation

@dilame
Copy link

@dilame dilame commented Dec 19, 2023

Fixes #756.

Key Change:

  • Addition of "type": "module" in package.json.

Issue Background:

  • The problem arises due to TypeScript's reliance on the package.json type field to determine the module format (CommonJS or ECMAScript Module, ESM) of a project.
  • In the absence of the type field, TypeScript, along with Node.js, defaults to interpreting modules as CommonJS. This becomes an issue when dealing with .d.ts files, as they do not specify the module system (like .mjs or .cjs would).
  • Consequently, when an ESM is imported in such a scenario, TypeScript incorrectly assumes it to be a CommonJS module, leading to module resolution conflicts described in error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls #756.

Thank you for considering this pull request!

@oliverjohns
Copy link

Ivan Hofer passed away. Im not sure there is any one that can approve this PR

@timofei-iatsenko
Copy link

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 this pull request may close these issues.

error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls

3 participants