fix(types): require send() payload when Reply type is specified#6432
Merged
mcollina merged 2 commits intofastify:mainfrom Jan 3, 2026
Merged
fix(types): require send() payload when Reply type is specified#6432mcollina merged 2 commits intofastify:mainfrom
mcollina merged 2 commits intofastify:mainfrom
Conversation
When a Reply type is explicitly provided, the `send()` method now requires a payload argument instead of making it optional. This improves type safety by catching cases where developers forget to send a response. The behavior is: - When ReplyType is `unknown` (default): payload is optional - When ReplyType is `undefined` or `void`: payload is optional - Otherwise: payload is required Closes fastify#5534
901a316 to
a4ec9db
Compare
a4ec9db to
189b59a
Compare
Eomm
approved these changes
Jan 2, 2026
|
Hi, this includes a breaking change but didn't trigger a major release |
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
When a
Replytype is explicitly specified, thesend()method now requires a payload argument instead of making it optional. This prevents silent bugs where developers forget to send the expected response type.Closes #5534
Changes
SendArgs<ReplyType>helper type intypes/type-provider.d.tsto determine payload requirementsend()method signature intypes/reply.d.tsto use spread parameters withSendArgssend()without arguments errors when Reply type is specifiedsend()without arguments is valid when Reply isvoid,undefined, or unspecifiedBehavior
send()payloadunknown(default)voidundefined{ test: boolean })Example
AI Assistance Disclosure
I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.