chore: upgrade TypeScript to 6.0 - #160
Merged
Merged
Conversation
Contributor
Author
|
commit be13c84: ts-jest floor 提到 ^29.4.7。已用 |
This was referenced Aug 22, 2026
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.
Closes #159
改动
package.json:tsconfig.json:TS 6 改变了两个 compiler defaults,需要显式固定(零源码修改):"esModuleInterop": true, "isolatedModules": true, + // TS 6 flips the effective noImplicitAny default to true. Pinned to keep + // the upgrade diff behavior-preserving; see format-lint-report.ts for the + // known implicit-any sites awaiting cleanup. + "noImplicitAny": false, + // TS 6 no longer infers rootDir (aka.ms/ts6, error TS5011). The JSON + // import of ../package.json makes the effective root the project + // directory, which preserves the lib/src/** emit layout. + "rootDir": "./",两个默认值变化的处理
1.
noImplicitAny有效默认值翻转为trueTS 5.9 下 typecheck 通过的代码在 TS 6 报出 6 个隐式 any(集中在
format-lint-report.ts:text-table无类型声明 + 3 个回调参数)。按"升级 PR 不顺手做类型收紧"的原则,显式"noImplicitAny": false固定原语义。隐式 any 清理留作独立后续 PR。2.
rootDir不再自动推断(TS5011,aka.ms/ts6)tsc -p tsconfig.json整体编译能推断;但 ts-jest 逐文件编译时推断结果不稳定,25 个 suite 全部失败。显式"rootDir": "./"——当前有效值就是项目根目录(../package.json的 JSON 导入把根拉进了编译程序),emit 路径不变。ts-jest floor 是 TS 6 的必要配套
实测上游 peer contract(npm view):
"typescript": ">=4.3 <6"— 不支持 TS 6"typescript": ">=4.3 <7"— 正式加入 TS 6 支持原声明
^29.4.0会允许typescript 6.0.3 + ts-jest 29.4.0~29.4.6这类不属于上游支持范围的组合。CI 全绿只能证明本次解析出的版本能跑,不能证明 floor 正确。因此提到^29.4.7——这不是顺手升级,是 TypeScript 6 的 compatibility floor。版本选择
停在 6.x(^6.0.3),不跟 TS 7.0.2:ts-jest 29.4.12 的 peer contract 是
>=4.3 <7,TS 7 迁移涉及 native compiler 兼容方案,是独立课题。验证
npm run typechecknpm test -- --runInBandnpm run buildlib/src/lint-md.js、lib/src/utils/lint-worker.js不变,仍为 CJSnpm run test:package源码 diff:0 文件。