fix(app-shell): 让 spec-symbol-parity 的「编译期」断言真的被 CI 编译 (#3181) - #3187
Merged
Conversation
…assertions (#3181) The file's `type _X = Assert<Equal<A, B>>` lines were never read by any compiler. `packages/app-shell/tsconfig.json` is the BUILD config and excludes `**/*.test.ts`; CI's only type gate drives that config (`pnpm type-check` -> turbo -> per-package `tsc --noEmit`), eslint is not type-aware, and vitest erases types before it runs. A provably-false `Assert<Equal<1, 2>>` appended to the file passed `pnpm type-check` at exit 0 — the same "declared != enforced" landmine the file's own header cites #3009 for. Adds `packages/app-shell/tsconfig.typetests.json`: an emit-free project with an EXPLICIT include list (not a glob), chained from the package's `type-check` script so it runs in the existing CI `Type Check` job. The list is explicit because app-shell's wider test tree still has a pre-existing error backlog, already declared as TEST_DEBT — a glob would sweep that in and the project would get deleted rather than fixed. That backlog stays tracked in #3181. `scripts/check-type-check-coverage.mjs` grows the matching ratchet: a `tsconfig.typetests.json` that `type-check` does not chain, that emits, or that includes no test file is now a hard failure, so this gate cannot go quiet the same way the assertions did. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ5
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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 #3181
问题
packages/app-shell/src/__tests__/spec-symbol-parity.test.ts里那些type _X = Assert< Equal< A, B > >从来没有被任何编译器读过:packages/app-shell/tsconfig.json是构建配置,exclude掉了**/*.test.ts(正确 —— 否则测试会 emit 进dist);pnpm type-check→ turbo → 每包tsc --noEmit);于是在该文件末尾追加一个必然为假的
Assert< Equal< 1, 2 > >,pnpm type-check依然 exit 0。这个文件自己的头注释引用 #3009 批评的正是这种「declared ≠ enforced」地雷,而它自己就踩在上面。#3185 刚刚反转的DecisionOutputDefpin 在此之前也只是装饰。改动
packages/app-shell/tsconfig.typetests.json——noEmit的独立 project,显式列出文件名,不用 glob。packages/app-shell/package.json:"type-check": "tsc --noEmit && tsc -p tsconfig.typetests.json",并另给一个type-check:typetests方便本地单跑。链在type-check上是本仓既有约定(见packages/types),也意味着它直接落在现有 CIType Checkjob 里,不需要新增 workflow 步骤。scripts/check-type-check-coverage.mjs增加对应棘轮:若某包存在tsconfig.typetests.json而type-check没有 chain 它、或它会 emit、或它的 include 里一个测试文件都没有,则直接失败。否则今天修好的 gate 明天会以同样的方式悄悄失效(这是 issue 里的方案 3)。为什么显式列文件,而不是把
exclude里的 test glob 拿掉app-shell 的测试树还有大量既有类型错误(
check-type-check-coverage.mjs的TEST_DEBT里记着 53 个;issue 用另一套配置量到 189 个)。用 glob 会把这些一次性扫进来,结果不是有人去修,而是下一个 agent 直接删掉整个 project。全量修复明确不在本 PR 范围内,继续留在 #3181 正文里跟踪。同理,这个文件没有命名为
tsconfig.test.json:那个名字在本仓的含义是「本包所有测试都编译」,coverage guard 会据此要求删掉TEST_DEBT条目 —— 那只是把一个假的「已检查」换成另一个假的「已检查」。关于 changeset
纯 CI/工具链改动,对已发布产物无行为影响,按 AGENTS.md「纯 bug 修复不需要 changeset」处理;
changeset-checkjob 只校验 fixed 组完整性,不要求每个 PR 带 changeset。验证
1. 正向:新 gate 在干净 main + 本改动上通过
2. 反向对照:追加一个必然为假的断言
在
spec-symbol-parity.test.ts末尾临时追加type _Probe = Assert< Equal< 1, 2 > >;。旧 gate(本 PR 之前 CI 唯一跑的那个)—— 依然放行,复现 issue:
新 gate —— 失败:
移除探针后重新变绿:
3. 反向对照:棘轮本身
把
type-check改回tsc --noEmit(即「配置还在,但没人跑它」):4. 运行时测试未受影响
5. CI
新 gate 走的是既有
Type Checkjob(pnpm type-check→ turbo → app-shell 的type-check),外加同 job 里已有的Verify type-check coverage步骤跑加固后的棘轮 —— 不是只存在于本地的 npm script。见本 PR 的 CI 检查结果。🤖 Generated with Claude Code
Generated by Claude Code