ci(typecheck): 棘轮开始检查测试层 —— 27 个"已覆盖"的包在藏自己的测试 (#4311) - #4348
Conversation
…ackages were hiding their tests (#4311) #4324 counted a package covered the moment it declared a `typecheck` script. But `tsc --noEmit` reads the package's own tsconfig.json, and 27 of the 48 packages that gate waved through `exclude` `**/*.test.ts` from exactly that file — so COVERED and REAL both passed while nothing read the test layer, which is the source #4311 is actually about. Measured by lifting each exclusion and re-running the package's own config: 568 test files, 1451 errors, behind a green check. `spec` alone hid 902 across 272 files; `plugin-approvals` hid 467, more than driver-sql's 241, with a clean src. What changed: 1. New TESTS_COVERED invariant + TEST_DEBT ledger in scripts/check-type-check-coverage.mjs. A package that excludes its own tests must carry a measured entry; RECONCILED runs both ways, so dropping the exclusion without deleting the entry fails, and so does the reverse. Test files are counted under the tsconfig's `include` roots — `exclude` only subtracts from what `include` selected, and several packages keep a sibling `test/` tree that `include` never mentions. Six new self-test cases (18 total). The summary line now prints both layers: reporting only the src figure is how 48/77 read as green over 568 unchecked files. 2. Nine packages that were already clean with tests included had the exclusion deleted outright: sdui-parser, plugin-audit, plugin-email, plugin-hono-server, plugin-pinyin-search, plugin-reports, trigger-api, trigger-schedule, connector-slack. 3. 44 relative imports repaired to carry the `.js` extension NodeNext requires. This was filed as config-tier noise and is not: an unresolved import degrades every symbol it names to `any`, and the callbacks over those symbols then report TS7006 "implicitly any". The 44 fixes closed 110 errors across eight packages — and exposed 12 real defects in service-settings (manifest action handlers called without `namespace`/`actionId`) that the broken imports had been masking. Its ledger entry said "no code-tier finding"; it was wrong in both directions, and now says so. 4. Nine packages graduate out of DEBT (types, create-objectstack, service-cache, service-i18n, service-job, service-messaging, service-queue, service-realtime, plugin-approvals). Three tsconfig repairs: `types:["node"]` for types (107 errors, one line), `exclude: src/templates` for create-objectstack (scaffolding copied verbatim by tsup, whose imports resolve in the generated project, not this one), `lib: ES2021` for plugin-approvals (String.replaceAll). plugin-approvals graduates on src only and carries a TEST_DEBT entry — its 13 test files are still excluded. Coverage: 48/77 -> 57/77 src-covered; DEBT 29 -> 20 entries (679 raw errors); TEST_DEBT 21 entries (652 files, 2243 raw errors) newly visible. No non-test source file changes. Verified: self-test 18/18, coverage gate, `turbo run typecheck` 119/119, `pnpm test` 132/132, eslint, check:published-files. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011m13wbaZziPveBdtQthrXd
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
📓 Docs Drift CheckThis PR changes 18 package(s): 29 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
承接 #4324。上一个 PR 立了覆盖棘轮,但它有个洞:只要包声明了
typecheck脚本就算覆盖。而tsc --noEmit读的是包自己的tsconfig.json——被它放行的 48 个包里,有 27 个在那个文件里exclude了**/*.test.ts。于是 COVERED 和 REAL 双双通过,而测试层没有任何人读过——测试层恰恰是 #4311 真正针对的地方。实测
逐包把 exclude 掀掉、用它自己的配置重跑
tsc --noEmit:568 个测试文件、1451 个错误,藏在绿色对勾后面。
specplugin-approvalsruntimeobjectqlplugin-authrestplugin-approvals一个包就比driver-sql的 241 还多,而它的 src 是干净的——这 467 个错误对今天所有门禁都不可见。改了什么
新增
TESTS_COVERED不变量 +TEST_DEBT台账。排除自己测试的包必须带实测条目;RECONCILED 双向生效——删了 exclude 却留着条目会报错,反之亦然。测试文件按 tsconfig 的include根来数:exclude只从include选中的集合里做减法,而有几个包的同级test/目录include根本没提,算进去等于把文件归咎于一个与它无关的 exclude。新增 6 个自测用例(共 18 个)。汇总行现在同时打印两层——只报 src 那个数字,正是 48/77 能在 568 个未检查文件之上显示为绿色的原因。9 个包直接删掉 exclude(纳入测试后本就干净,零成本):
sdui-parser、plugin-audit、plugin-email、plugin-hono-server、plugin-pinyin-search、plugin-reports、trigger-api、trigger-schedule、connector-slack。44 个相对导入补上 NodeNext 要求的
.js后缀。这件事此前被归为 config-tier 噪音,它不是:导入解析不了,它引入的每个符号都退化成any,而这些符号上的回调随即报 TS7006 "implicitly any"。修完这 44 个导入,连带消掉 8 个包的 110 个错误(所谓 noise 大半根本不是 noise),同时暴露出service-settings里 12 个真实缺陷——manifest action handler 调用时缺namespace/actionId——此前一直被坏导入掩盖。它的台账条目写着"no code-tier finding",两个方向都是错的,现在改正了。9 个包从 DEBT 毕业:
types、create-objectstack、service-cache、service-i18n、service-job、service-messaging、service-queue、service-realtime、plugin-approvals。三处 tsconfig 修复:types加types:["node"]—— 一行消掉 107 个错误create-objectstack排除src/templates—— 脚手架模板由 tsup 原样cpSync拷贝、从不编译,其导入是在生成出来的项目里解析的,不是这个包里plugin-approvals加lib: ES2021——String.replaceAllplugin-approvals只以 src 毕业,同时带一条 TEST_DEBT——它那 13 个测试文件仍被排除。数字
没做什么
driver-sql241 +driver-sqlite-wasm27 +driver-memory23,共用同一 playbook)仍归 [P2] framework: 66 个包用 tsup 构建、无人做类型检查 —— 实测 18 个包共 380 处 code-tier 错误(#4118 的 framework 侧对应) #4311,适合单独集中修。service-settings新暴露的 12 个真实缺陷留在台账里,属 code-tier 工作。lib: ES2020相对仓库实际运行时是陈旧的(plugin-approvals就是撞在这上面)。这次按包最小化处理,没动根配置——改它会波及全部 48 个已覆盖的包。本地验证
--self-test18/18 ✅;覆盖门禁 ✅;turbo run typecheck(CI 同命令)119/119 ✅;pnpm test132/132 ✅;eslint ✅;check:published-files✅。没有改动任何非测试源文件——全部变更是测试文件的导入、tsconfig、package.json 脚本、文档和门禁脚本。空 changeset,不发版。
🤖 Generated with Claude Code
https://claude.ai/code/session_011m13wbaZziPveBdtQthrXd
Generated by Claude Code