fix: explicit tsconfig for ts-jest to resolve deprecated moduleResolution - #122
Merged
Merged
Conversation
…lution Agent-Logs-Url: https://github.com/USTC-KnowledgeComputingLab/ddss/sessions/14a89fad-9845-4157-bbb4-4f53ab473c94 Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Jest tsconfig to avoid deprecated moduleResolution
fix: explicit tsconfig for ts-jest to resolve deprecated moduleResolution
Apr 6, 2026
hzhangxyz
marked this pull request as ready for review
April 6, 2026 11:15
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ts-jestdefaults tomoduleResolution: node10when no tsconfig is provided, triggering TS5107 (deprecated, breaks in TypeScript 7.0). The project'stsconfig.jsonalready specifiesmoduleResolution: bundler—ts-jest just wasn't using it.Change
jest.config.js: Passtsconfig: "<rootDir>/tsconfig.json"explicitly to the ts-jest transform, so it inherits the project's compiler options instead of falling back to its own deprecated defaults.Original prompt
Create a PR targeting
mainbased on the current Dependabot branchdependabot/npm_and_yarn/npm-dependencies-2a9de1d360(head SHA55c4666b14ea45bd854da70afe97856c82bfb1ce).The GitHub Actions workflow
Jestis failing duringnpm run testwith TypeScript error:TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0.Goal: Apply best practice with minimal file changes (preferably only 1 file) and do not solve by adding
ignoreDeprecations.Proposed fix:
jest.config.jsto passtsconfig: "<rootDir>/tsconfig.json"in the ts-jest transform options.Files to inspect/modify:
jest.config.jscurrently:tsconfigoption.Validation:
npm run testpasses locally/CI.includenot coveringtests/*, apply the smallest additional change needed (prefer updatingtsconfig.jsoninclude to add tests). Only do this if required by the test run.Context:
.github/workflows/jest.ymlrunsnpm run allon Node 20/22/24."type": "module"in package.json).Please open the PR with a clear title and description referencing the failing TS5107 error and the fix rationale.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant: The job is failing before any tests run because TypeScript treats a deprecated setting as an error:
This is coming from the TypeScript compiler options being picked up by
ts-jestduringnpm run all(which runs Jest). Even though your repotsconfig.jsonshows"moduleResolution": "bundler", the error indicates another tsconfig is being used in the Jest/ts-jest path (commonlytests/tsconfig.json,tsconfig.test.json, or a default ts-jest config), and that config still hasmoduleResolution: "node10".Fix (preferred): stop using
node10module resolution in the tsconfig used by testsglobals['ts-jest'].tsconfigor ats-jestpreset).to one of:
or (if you’re fully ESM/bundler-oriented):
This removes the deprecated option entirely, so it will keep working as TypeScript evolves.
Fix (quick unblock): silence the deprecation error
In the tsconfig that currently contains
"moduleResolution": "node10", add:{ "compilerOptions": { "ignoreDeprecations": "6.0" } }This aligns exactly with the compiler’s instruction in the log and will make CI pass again, but it’s better to also migrate off
node10rather than relying on the ignore.Optional hardening (make Jest explicitly use the intended tsconfig)
To prevent Jest from accidentally picking up an old/secondary tsconfig, explicitly point ts-jest to your repo
tsconfig.jsoninjest.config.js:Why this fixes the CI matrix
Your workflow runs Node
20,22, and24. Newer TypeScript versions (or stricter defaults in the toolchain) will surface this deprecation as an error across the matrix. Removingnode10(or addingignoreDeprecations) resolves the compilation step so Jest can actually execute the tests.User: 用中文回复我,大概发生什么了?
User: 用中文回复我,大概发生什么了?
Assistant: 这次 CI(GitHub Actions 的 Jest job)其实还没开始跑任何测试就挂了,原因是 TypeScript 编译配置里出现了一个已被弃用的选项,并且在你当前的工具链版本下被当成“错误”处理了。
从日志里最关键的一行是:
TS5107: Option 'moduleResolution=node10' is deprecated ..."ignoreDeprecations": "6.0"来压掉这个报错大概发生了什么?
npm run all(先 build 再 test)。在 test 阶段,Jest 用ts-jest去加载并编译你的tests/*.ts。ts-jest在编译时会读取某个tsconfig(TypeScript 配置)。moduleResolution: "node10"。node10这种 moduleResolution 现在已经被 TypeScript 标记为 deprecated(弃用),在当前环境中直接报错TS5107,导致整个 test suite 直接失败(所以你看到 7 个 test 文件都 “Test suite failed to run”,但 Tests: 0)。为什...
This pull request was created from Copilot chat.