Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the full one-commit diff of PR #2033, which relaxes the type-parameter requirement for the ratelimit middleware.
- Defaulted input type —
RateLimitMiddlewareOptions<TInContext, TInput = unknown>(middleware.ts:22) andratelimit<TInContext, TInput = unknown>(middleware.ts:61) now allow a standalone middleware definition with only the context type argument. The declared return typeMiddleware<TInContext, object, TInput, any, object>is unchanged, so this is backwards compatible — the default only applies when inference yields no candidate, and inline.use(ratelimit({...}))still infersTInputfrom the call site. - Standalone type tests — the new
describe('ratelimit standalone')block pins the one-argument factory call and the one-argument options type, assertsinputisunknownin both callbacks, and keeps the@ts-expect-errorfor a context missingrateLimiter, so the default doesn't loosen context checking.
Verified locally: root tsc -b . exits 0 (the root tsconfig is what validates *.test-d.ts) and eslint --max-warnings=0 on both changed files exits 0. unknown is the sound choice over any here — accessing an unknown field still requires narrowing.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Contributor
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.

ratelimitandRateLimitMiddlewareOptionsnow defaultTInputtounknown. Defining the middleware standalone only needs the context type argument, e.g.ratelimit<{ ratelimiter: RateLimiter }>({ ... }), where TypeScript previously demanded both type arguments.Behavior
unknownand the middleware plugs into any procedure input..use(ratelimit({ ... }))is unchanged, since both type arguments are still inferred from the call site.Testing