fix(scripts): 删除 check-doc-links 测试中已失效的 @ts-expect-error(修复净 main 上的 TS2578) - #3505
Merged
Conversation
净 main 上 `pnpm type-check:scripts` 红:
scripts/__tests__/check-doc-links.test.ts(7,1):
error TS2578: Unused '@ts-expect-error' directive.
这是两个各自绿的 PR 合并后产生的语义冲突:
- #3489(449227d)新增该测试时带 `@ts-expect-error`,当时正确 ——
彼时没有任何 tsc 程序 include `scripts/`,该导入确实无类型。
- #3498(f995a45)引入 `tsconfig.scripts.json`(`allowJs: true`),
首次把 `scripts/**/*.ts` 纳入类型检查。`allowJs` 让 `.mjs` 助手的
类型可被推断,于是所有这类压制注释同时变成 Unused。#3498 修掉了它
base 上的 5 处同类,而 #3489 的第 6 处恰好落在其窗口之间。
两 PR 的 CI 各自为绿,合并结果为红 —— 当前所有 PR 的 Type Check 全部误红。
仅删除该行。运行期行为从不依赖该指令(它只影响 tsc,不影响 vitest),
`check-doc-links.test.ts` 22 个用例保持全绿。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This was referenced Aug 7, 2026
yinlianghui
marked this pull request as ready for review
August 7, 2026 02:10
This was referenced Aug 7, 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.
Fixes #3504
症状
净
origin/main(f995a45)上pnpm type-check:scripts红:CI 的
type-checkjob 跑的就是这条命令,因此当前所有开着的 PR 的 Type Check 全部误红 —— 红的不是它们的改动。成因:两个各自绿的 PR 合并后的语义冲突
这是典型的 semantic conflict:两个 PR 在文本上毫不相干、各自 CI 全绿,合并结果为红。
PR fix(docs): check-doc-links 解析相对链接,并修掉它现在能看见的 16 个失效目标 (#3479) #3489(449227d) 新增
scripts/__tests__/check-doc-links.test.ts,导入行上带@ts-expect-error — plain-JS CI helper, intentionally untyped。写下时是正确的:彼时仓库里没有任何 tsc program
include了scripts/(根tsconfig.json只含packages/examples/apps),该.mjs导入确实无类型可用,压制注释既无害也无人检验。PR ci(scripts): 用独立 tsconfig.scripts.json 给 scripts/ 补上类型门 (#3494) #3498(f995a45) 引入
tsconfig.scripts.json,首次把scripts/**/*.ts纳入类型检查,并且经过实测选择了allowJs: true(见该文件内的长篇注释)。allowJs让.mjs助手的类型从助手自身推断得到,于是所有这类压制注释在同一瞬间集体变成 Unused。ci(scripts): 用独立 tsconfig.scripts.json 给 scripts/ 补上类型门 (#3494) #3498 已经修掉了它 base 上的 5 处同类。fix(docs): check-doc-links 解析相对链接,并修掉它现在能看见的 16 个失效目标 (#3479) #3489 的这第 6 处恰好落在 ci(scripts): 用独立 tsconfig.scripts.json 给 scripts/ 补上类型门 (#3494) #3498 开分支与合并之间的窗口里 —— 对 ci(scripts): 用独立 tsconfig.scripts.json 给 scripts/ 补上类型门 (#3494) #3498 不可见,而 fix(docs): check-doc-links 解析相对链接,并修掉它现在能看见的 16 个失效目标 (#3479) #3489 那边根本没有任何东西 type-check 它。两边 CI 都绿,merge base 之后才红。
换句话说:压制注释没有"错",是它脚下的地基(类型门的覆盖面)变了。
改动
只删掉那一行,不动其它任何东西:
-// @ts-expect-error — plain-JS CI helper, intentionally untyped import { collectBrokenLinks, routeExists, stripCode } from '../check-doc-links.mjs';一个文件,一行,
1 file changed, 1 deletion(-)。无 changeset —— 改动在scripts/下的 CI 测试文件里,不是任何已发布包的一部分,对用户不可见。验证
先在净
origin/main(未做任何改动、git status干净)上复现,再改,再复跑:pnpm type-check:scriptsTS2578at (7,1)pnpm type-check:scriptspnpm exec vitest run scripts/__tests__/check-doc-links.test.ts --maxWorkers=2Test Files 1 passed (1)/Tests 22 passed (22)node scripts/check-control-bytes.mjsOK (scanned 3686 tracked text file(s); skipped 85 binary)运行期行为从不依赖该指令:
@ts-expect-error是纯 tsc 编译期构造,vitest 经 esbuild 转译时把它当普通注释剥离,对collectBrokenLinks/routeExists/stripCode的实际导入与执行零影响。所以这里 22 个用例保持全绿是预期方向,而不是"测试没覆盖到"的空绿 —— 真正把这次改动钉住的是type-check:scripts由红转绿这一条。另在被改文件上做了超出门禁扫描面的控制字符自查(
grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f]',无命中;file报 UTF-8 text)。后续(不在本 PR 范围)
本 PR 是止血,刻意只删这一行。这类"新类型门上线 + 并行 PR 在窗口期落地旧式压制"的碰撞会重演;是否需要一条更结构化的防线(例如让 #3498 那类覆盖面扩张 PR 在合入前对
origin/main最新态复跑一次,或把type-check:scripts纳入 merge queue 的必需检查),留给维护者判断,未在此另开 issue。Generated by Claude Code