-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
area: integrationsrelated to working with 3rd party software (e.g., babel, typescript)related to working with 3rd party software (e.g., babel, typescript)status: wontfixtypically a feature which won't be added, or a "bug" which is actually intended behaviortypically a feature which won't be added, or a "bug" which is actually intended behaviortype: buga defect, confirmed by a maintainera defect, confirmed by a maintainer
Description
Bug Report Checklist
- I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
- I have searched for related issues and issues with the
faqlabel, but none matched my issue. - I have 'smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, my usage of Mocha, or Mocha itself.
- I want to provide a PR to resolve this
Expected
Combining mocha with tsx and ESM, and importing an interface without using import type should work.
Actual
Mocha throws an error when that combination of features is used.
Minimal, Reproducible Example
- Clone https://github.com/fvictorio/mocha-5452
- Run
npm install && npx mocha test.ts. You'll get an error likeException during run: Error [ERR_INTERNAL_ASSERTION]: Unexpected status of a module that is imported again after being required. Status = 0. This is caused by π Bug: Unhelpful error message when a default import is made from a module without a default exportΒ #5411, which was already fixed. But using the 11.7.2 version of mocha still results in an error, just with a better message:Exception during run: SyntaxError: The requested module './foo.js' does not provide an export named 'Foo'.
If I change import { Foo } to import type { Foo }, things work.
Running the same file directly by doing node --tsx/esm test.ts works fine, which is what makes me think that this is a mocha issue.
Versions
Using the version in main:
$ npx mocha --version
11.7.1
$ /node_modules/.bin/mocha --version
11.7.1
$ node --version
v24.7.0
Additional Info
No response
Metadata
Metadata
Assignees
Labels
area: integrationsrelated to working with 3rd party software (e.g., babel, typescript)related to working with 3rd party software (e.g., babel, typescript)status: wontfixtypically a feature which won't be added, or a "bug" which is actually intended behaviortypically a feature which won't be added, or a "bug" which is actually intended behaviortype: buga defect, confirmed by a maintainera defect, confirmed by a maintainer
Type
Projects
Status
Backlog