build(typecheck): cover tests/ and scripts/ in pnpm typecheck#81
Merged
Conversation
- add tsconfig.typecheck.json (extends base, noEmit, rootDir ".") including src+tests+scripts; repoint `typecheck` script to it — build/prepare tsc stays on the base config and emits src -> dist only (package unchanged) - fix 54 type errors surfaced in test/script files (index guards, complete mock objects, MCP resource-content union narrowing via a firstText helper); no assertion weakened, src untouched - add tests/contract/typecheck-config.test.ts guarding the coverage (mutation-verified: re-excluding tests turns it red) - sync test counts 2079 -> 2083; note typecheck coverage in tests README - closes the PB-008 gate blind spot: test-file type breaks now fail typecheck/CI instead of only being caught at adversarial review
- typecheck now covers tests/ + scripts/ (PB-008 gate closed); quick scale, no feature-spec graduation (dev-tooling, no product-spec impact) - add _archived-history summary; refresh raw-scan.md
Prospec Check |
Test Coverage
|
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.
問題
pnpm typecheck(tsc --noEmit)用的tsconfig.json只includesrc/**、exclude含tests,所以測試檔從不被型別檢查。測試檔的型別破損(如遷移型別後仍從舊模組import type→ TS2459)會逃過typecheck、test(esbuild 於 runtime strip type-only import)、lint三閘,只能靠對抗式 review 抓到——這正是 PB-008 記錄的 gate 盲點(源於 PR #80 review 揪出的一個 latent TS2459)。方案
tsconfig.typecheck.json:extends ./tsconfig.json、compilerOptions.noEmit: true+rootDir: "."(消除 TS6059),includesrc/tests/scripts,excludenode_modules/dist。pnpm typecheck改指向它;build/prepare(tsc)維持用 basetsconfig.json,只 emitsrc→dist(套件產物不變,dist/不含 tests)。scripts/counts/rewrite.ts):index guard、補齊 mock 物件、MCP resource-content union 收窄(抽firstTexthelper);未弱化任何斷言、src/未動。tests/contract/typecheck-config.test.tsguard:釘住「typecheck config 涵蓋 tests」(section-scoped + 負向 exclude 斷言 + script 連動),mutation-verified——重新排除 tests 即轉紅。效果
測試檔的型別破損現在在
pnpm typecheck/ CI 直接 FAIL,不再只能靠對抗式 review。PB-008 的盲點就此關閉;ci.yml已跑pnpm run typecheck,故 CI 自動涵蓋,無需另加步驟。測試 / 品質
pnpm typecheck0 errors(含 tests+scripts)、pnpm test2090 passed、pnpm lintclean、prospec check11/11。SDD
透過 Prospec SDD 完成:story → tasks(quick,plan-time 探測後由 standard 改判)→ implement → review(clean)→ verify(grade S)→ archive。內部 dev-tooling、無 product-spec 影響,故無 feature-spec graduation。獨立於已合併的 #80。