ci: typecheck ordinary test sources - #1819
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (15)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe PR corrects the ChangesDistinct output contract
Test-source typecheck pipeline
Offline transaction test type safety
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The change is ready to merge: no actionable behavior, API-contract, or CI-gate risk remains in the supplied evidence. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 11 files. (4 skipped: 4 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
More templates
@tanstack/angular-db
@tanstack/browser-db-sqlite-persistence
@tanstack/capacitor-db-sqlite-persistence
@tanstack/cloudflare-durable-objects-db-sqlite-persistence
@tanstack/db
@tanstack/db-ivm
@tanstack/db-sqlite-persistence-core
@tanstack/electric-db-collection
@tanstack/electron-db-sqlite-persistence
@tanstack/expo-db-sqlite-persistence
@tanstack/node-db-sqlite-persistence
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/react-native-db-sqlite-persistence
@tanstack/react-router-with-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/tauri-db-sqlite-persistence
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: 0 B Total Size: 165 kB ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 7.34 kB ℹ️ View Unchanged
|
Adds an explicit CI gate for ordinary TypeScript test sources in
db-ivmandoffline-transactions, then fixes the existing strict-type errors that gate exposes. CI will now reject test-only type regressions that runtime tests and declaration builds previously missed.Root Cause
The PR workflow only ran the workspace build and runtime tests. Those checks do not cover ordinary
.test.tssources: declaration generation is scoped to production source directories,offline-transactions' package typecheck was never invoked from root CI, and db-ivm's Vitest typechecking defaults only include type-test files such as*.test-d.ts.As a result, stale fixture shapes, unchecked indexed access, mismatched callback signatures, and an incorrect public
distinctreturn annotation could remain green in CI.Approach
typecheck:testscommand covering@tanstack/db-ivmand@tanstack/offline-transactions, and run it as a distinct PR workflow step after package builds.distinct's declared output from the input tuple type toKeyValue<number, GetValue<T>>, matching the numeric hash keys it already emits at runtime.Key Invariants
distinctruntime behavior is unchanged; only its public return type now describes the values already emitted.Non-goals
Trade-offs
This adds a dedicated typecheck step to PR CI, increasing check time slightly in exchange for making test-source type safety explicit and independently visible. The
distinctcorrection is a public type change, but it replaces an impossible type promise with the operator's existing runtime contract.Verification
The db-ivm suite passed 357 tests. The offline-transactions suite passed 65 tests with one pre-existing skip. A temporary intentional type error in an ordinary
.test.tsfile was rejected bypnpm run typecheck:testsand removed before commit.Files changed
.github/workflows/pr.yml: separates build, test-source typechecking, and runtime tests into explicit CI steps.package.json: adds the root test-source typecheck target.packages/db-ivm/package.json: adds db-ivm'stsc --noEmittarget.packages/db-ivm/src/operators/distinct.ts: aligns the public stream return type with numeric emitted keys and preserved values.packages/db-ivm/tests/graph.test.ts: narrows indexed messages after length assertions.packages/db-ivm/tests/operators/distinct.test.ts: updates tracker and message types to the actual distinct output.packages/db-ivm/tests/operators/filterBy.test.ts: narrows indexed messages after length assertions.packages/db-ivm/tests/operators/join.test.ts: narrows an indexed message after the non-empty assertion.packages/db-ivm/tests/test-utils.ts: narrows the sole positive value after its length check.packages/db-ivm/tests/utils.test.ts: invokes leaf factories with callback-compatible wrappers.packages/offline-transactions/tests/TransactionSerializer.test.ts: replaces incomplete cast fixtures with typed collections, complete transactions, and safe value guards.packages/offline-transactions/tests/harness.ts: accepts real pending mutation shapes, validates test items, supports synchronous mutation callbacks, and removes broad result typing.packages/offline-transactions/tests/leader-failover.test.ts: removes mutation casts and narrows indexed outbox entries.packages/offline-transactions/tests/offline-e2e.test.ts: removes mutation casts and narrows indexed outbox entries..changeset/fix-distinct-output-type.md: records the db-ivm patch-level type correction.Fixes #1812
Summary by CodeRabbit
Bug Fixes
distinctoperator’s output type to accurately represent numeric keys while preserving the original values.Tests