Repository navigation
test: bring packages/swr/tests under the scoped typecheck gate - #743
Merged
Merged
Conversation
pnpm typecheck:files failed on any edited swr test file (untyped devtools Window globals, untyped .tsrx fixture props, Middleware/Cache contract violations) while repo-wide typecheck never checks packages/swr/tests. Add a tests-scoped tsconfig + tests-local Window d.ts (nothing ships: the tarball is src-only), give the differential lane its own tsconfig so the ambient augmentation cannot un-use the vendored upstream's @ts-expect-error, add types:["node"] to the tsgo-checked conditions lanes, and fix the test-side type errors within public contracts. Co-Authored-By: Claude Fable 5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
trueadm
marked this pull request as ready for review
August 12, 2026 20:32
This branch was previously deployed
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.
Summary
pnpm typecheck:files(the prescribed pre-push gate) failed on any edited swr test file, while repo-widepnpm typechecknever looked atpackages/swr/testsat all (packages/swr/tsconfig.jsonincludes onlysrc). The visible symptom was TS2339 onwindow.__SWR_DEVTOOLS_OCTANE__/__SWR_DEVTOOLS_REACT__, but the baseline scoped run also failed on untyped.tsrxfixtureprops, a() => undefinedsentinel passed asMiddleware, andcache.clear()(the publicCachecontract haskeys()/delete(), noclear()). This PR makes the swr tests tree typecheck-clean under the scoped gate without shipping anything to the tarball.Why
scripts/typecheck-files.mjsresolves ownership by walking up to the nearest tsconfig and only auto-includes the owning project's.d.tsfiles. Withpackages/swr/tsconfig.json(src-only) as the fallback owner, no tests-local ambient declaration could ever be seen, so the devtoolsWindowglobals — installed at runtime viaObject.definePropertyinsrc/_internal/devtools-contract.ts(the settledOCTANE DIVERGENCE[swr-devtools-global], untouched here) — had no importable or ambient type.src/: the package publishes"files": ["src", …], and a shipped ambientWindowaugmentation would apply to every consumer program.Changes
packages/swr/tests/tsconfig.json(modeled on the existingtests/adoption/tsconfig.json) owns the tests tree for the scoped gate, excludingdifferentialandprobes/conditions, which need different programs. Newpackages/swr/tests/global.d.tsdeclares the two devtools globals as optionalunknown(root.test.tsdeletes them), test-side only.packages/swr/tests/differential/tsconfig.json: the differential tests compile the byte-pinned vendoredupstream/src, where the ambient augmentation would turn upstream's@ts-expect-erroronwindow.__SWR_DEVTOOLS_REACT__ = Reactinto a fresh TS2578. A lane-local tsconfig keepsglobal.d.tsout of that program; the differential test files themselves are sha256-pinned inaudit/react-parity.jsonand are not modified."types": ["node"]added to the threeprobes/conditions/tsconfig.*.jsonlanes and the new differential tsconfig: they check undertsgo, which does not auto-include visible@types, so octane'sruntime.tsfailed with TS2591Cannot find name 'process'(pre-existing; every other tsgo project in the repo already declares"types": ["node"]).propsper the tsrx authoring rule (upstream/root/fixtures.tsrx,upstream/specialized/fixtures.tsrx,probes/external-store.tsrx) against the port's real exported types, typed two callback params inspecialized.test.ts, and made themergeConfigssentinels inunit/core.test.tsrealMiddlewareidentities.cache.clear()cleanup sites withfor (const key of [...cache.keys()]) cache.delete(key)— behaviorally identical on the default Map-backed cache and inside the publicCachesurface.Validation
pnpm format:checkpnpm typecheck(repo-wide, green — the fixed-plist is unaffected by the new tests tsconfigs)pnpm test— ran the full root Vitest run twice locally; 20,9xx tests pass. Each run had a different small set of failures confined to real-browser/server-spawning suites outside this diff (octane-events-browsernative-change with a Vite504 Outdated Optimize Depload error,doom-browserpointer-lock,website-mcp-unitplumbing). All three files pass 28/28 when run directly, so these are local parallel-load flakes, not regressions from this change; nothing in this diff is imported by them.pnpm typecheck:files packages/swr/tests/upstream/root/root.test.ts packages/swr/tests/unit/core.test.ts packages/swr/tests/probes/architecture.test.ts(passes; previously 17 errors),tsrx-tsc --noEmit -p packages/swr/tests/tsconfig.json(whole tests project clean), scoped runs of theprobes/conditionslanes (clean),vitest run --project swr(35/35) and--project swr-differential(4/4),pnpm tsrx-decls:check,pnpm sync(no generated changes)Risk / follow-ups
upstream/src/index/use-swr.ts(329)TS2578 (upstream builds withnoUnusedLocals, which this repo's configs don't set; enabling it in the lane trips over two intentionally-unused declarations in octane'sruntime.ts). Unchanged from baseline — fixing it needs an octane-core edit and is spun off separately.packages/swr/testsstays out of repo-widepnpm typecheckon purpose: no other package gates its tests dir there, and the scoped pre-push gate now covers the tree.Provenance
agent-authored)Note
Low Risk
Test-only TypeScript and cleanup changes; no production
srcor consumer-facing behavior.Overview
Adds
packages/swr/tests/tsconfig.json(excluding differential andprobes/conditions) plus atests/global.d.tsWindowaugmentation for devtools globals sopnpm typecheck:fileson swr tests is clean without shipping ambient types fromsrc. A separatetests/differential/tsconfig.jsonkeeps that augmentation out of the byte-pinned upstream differential program.Probe condition tsconfigs and the differential config now set
"types": ["node"]for tsgo. Test fixtures and a few unit tests gain explicit types (Middlewaresentinels,.tsrxprops, callback params), and teardown replacescache.clear()withfor (const key of [...cache.keys()]) cache.delete(key)to match the publicCacheAPI.Reviewed by Cursor Bugbot for commit a7a4491. Bugbot is set up for automated code reviews on this repo. Configure here.