Fix typecheck failure in example/convex/setup.test.ts#262
Conversation
commit: |
📝 WalkthroughWalkthroughThe PR updates the 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
Main has been failing `npm run typecheck` on every push since 2026-04-01, masking real type regressions in subsequent PRs. Root cause: commit e29f2bb made @convex-dev/agent's `register` signature generic, so it accepts a `TestConvex` with a specifically-inferred schema. But sibling components @convex-dev/workflow, /workpool, and /rate-limiter still shipped non-generic `register(t: TestConvex<SchemaDefinition< GenericSchema, boolean>>)`. TestConvex is invariant in its schema param, so a specifically-typed `t` is not assignable to the wider type, and the example's `initConvexTest` failed to type-check on lines 13-14. Fix: - Bump @convex-dev/workflow 0.3.6 -> 0.3.12 (now generic). - Add @convex-dev/workpool 0.4.6 explicitly as a dev dep so the transitive workpool is upgraded too (previously pinned at 0.3.1, still non-generic). Workflow's internal `workpool.register(t, ...)` call was itself failing with the older workpool. - Cast `t` only at the rate-limiter call: rate-limiter@0.3.2 is the latest published version and still has the non-generic signature, so this cast is a temporary workaround. A separate upstream PR genericizes rate-limiter's register; once a new rate-limiter ships, the cast can be removed. After this change: `npm run typecheck`, `npm test`, and `npm run lint` all pass.
f23b14d to
fb6b541
Compare
rag@0.7.2 pinned workpool to ^0.3.0, conflicting with the workpool 0.4.6 upgrade in the prior commit. rag@0.7.3 widens its peer to ^0.3.0 || ^0.4.0, so a clean npm install now works.
ianmacartney
left a comment
There was a problem hiding this comment.
I think we can drop this if we update convex-test
convex-test 0.0.52 relaxes TestConvex's schema-param variance enough that a specifically-typed `t` is now assignable to non-generic register signatures like @convex-dev/rate-limiter@0.3.2's. The workaround cast in initConvexTest is no longer needed.
Summary
Restores
npm run typecheckto green. Main has been failing on every push since 2026-04-01, masking real type regressions in subsequent PRs.Root cause
Commit e29f2bb ("better convex test types") made
@convex-dev/agent'sregistersignature generic. Sibling components didn't all follow:@convex-dev/agent@convex-dev/workflow@convex-dev/workpool@convex-dev/rate-limiterTestConvexis invariant in its schema parameter (it appears in both contravariant input positions liket.query(...)args and covariant return positions), so aTestConvex<SchemaDefinition<{ rawUsage: ..., invoices: ... }>>is not assignable toTestConvex<SchemaDefinition<GenericSchema, boolean>>even though the value is structurally compatible.Fix
@convex-dev/workflow0.3.6 → 0.3.12 (now generic).@convex-dev/workpool0.4.6 as an explicit dev dep so the transitive workpool is upgraded; workflow's ownworkpool.register(t, ...)would otherwise fail typecheck against the older 0.3.1 workpool.tonly at therateLimiter.register(...)call site — rate-limiter@0.3.2 is the latest published version and still has the non-generic signature. The cast is annotated as a temporary workaround; an upstream PR genericizes rate-limiter's register, and once a new release lands the cast can be deleted.Test plan
npm run typecheck— passes locally (was failing on main for ~6 weeks)npm test— all 262 tests passnpm run lint— cleanFollow-up
get-convex/rate-limiterto genericizeregister. Once shipped, drop the cast.