Genericize register signature in src/test.ts - #34
Conversation
Match @convex-dev/agent's and @convex-dev/workflow's generic register signature so callers can pass a TestConvex with a specifically-inferred schema. Previously, the non-generic `TestConvex<SchemaDefinition<GenericSchema, boolean>>` parameter prevented this — TestConvex is invariant in its schema parameter, so a specifically-typed `t` (e.g. from `convexTest(schema, modules)` with a real schema) was not assignable to the wider type, forcing downstream projects to add a type cast at the call site. After this change, callers can do: ```ts const t = convexTest(schema, modules); agent.register(t); workflow.register(t); rateLimiter.register(t); // no cast needed ``` No runtime change.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository: get-convex/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ 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 |
commit: |
|
@codex review |
|
If you install the latest |
|
It isn't giving errors on |
Summary
Match
@convex-dev/agent's and@convex-dev/workflow's genericregistersignature so callers can pass aTestConvexwith a specifically-inferred schema:Context
TestConvexis invariant in its schema parameter (it appears in both contravariant input positions liket.query(...)args and covariant return positions). That means aTestConvex<SchemaDefinition<{ tableA: ..., tableB: ... }>>returned byconvexTest(schema, modules)with a real schema is not assignable toTestConvex<SchemaDefinition<GenericSchema, boolean>>, even though the value is structurally fine.Downstream projects currently work around this with a cast at the call site:
@convex-dev/agentalready moved to a generic register signature in get-convex/agent@e29f2bb, and@convex-dev/workflowfollowed in 0.3.12. This PR brings rate-limiter in line so the cast can be dropped. See get-convex/agent#262 for the downstream context.Test plan
npm run typecheckpassesnpm test— all 94 tests passnpm run lintclean