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

[Bug]: Module Resolution Issue with ts-jest 29.2.4 and TypeScript ^4.x when using isolatedModules option #4521

Closed
Hoo93 opened this issue Aug 23, 2024 · 2 comments
Labels
🐛 Bug Confirmed Bug is confirmed

Comments

@Hoo93
Copy link

Hoo93 commented Aug 23, 2024

Version

29.2.4

Steps to reproduce

  1. Clone my repo at https://github.com/Hoo93/ts-jest-bug.git
  2. yarn install
  3. run jest

Expected behavior

The tests should execute without triggering the TS6046 error when isolatedModules is enabled.

Actual behavior

With ts-jest 29.2.4 and typescript ^4.x, enabling isolatedModules causes the TS6046 error to occur, suggesting that --moduleResolution is not being interpreted correctly.

Debug log

It only throw
error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.

Additional context

This issue seems to be related to how ts-jest handles TypeScript’s moduleResolution when isolatedModules is enabled. It may be that the TypeScript compiler options are not being correctly passed or parsed in this configuration.

Environment

System:
    OS: macOS 14.5
    CPU: (12) arm64 Apple M2 Pro
  Binaries:
    Node: 22.4.1 - /opt/homebrew/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.8.1 - /opt/homebrew/bin/npm
    pnpm: 9.5.0 - /opt/homebrew/bin/pnpm
  npmPackages:
    jest: ^29.7.0 => 29.7.0
@Hoo93 Hoo93 changed the title [Bug]: [Bug]: Module Resolution Issue with ts-jest 29.2.4 and TypeScript ^4.x when using isolatedModules Aug 23, 2024
@Hoo93 Hoo93 changed the title [Bug]: Module Resolution Issue with ts-jest 29.2.4 and TypeScript ^4.x when using isolatedModules [Bug]: Module Resolution Issue with ts-jest 29.2.4 and TypeScript ^4.x when using isolatedModules option Aug 23, 2024
@ahnpnl
Copy link
Collaborator

ahnpnl commented Aug 23, 2024

Duplicate with #4499 and we will release the fix in 29.2.5

besides, ts-jest and Jest 29 supports ts >= 4.8. If you are below 4.8, you should upgrade to 4.8 at least to be compatible

@Hoo93
Copy link
Author

Hoo93 commented Aug 23, 2024

@ahnpnl Thank you for your answer!
I upgraded the TypeScript version to 5, and everything works well now.”

@Hoo93 Hoo93 closed this as completed Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Confirmed Bug is confirmed
Projects
None yet
Development

No branches or pull requests

2 participants