Repository navigation
fix(types): export request and reply namespace type helpers - #434
Open
helmipradita wants to merge 1 commit into
Open
helmipradita wants to merge 1 commit into
helmipradita wants to merge 1 commit into
Conversation
SameRainbows
reviewed
Nov 1, 2026
SameRainbows
left a comment
There was a problem hiding this comment.
Nice work separating the namespace decorator typings.
A few key points verified:
- Preserving
FastifyJwtNamespaceas the intersectionFastifyJwtRequestNamespace<C> & FastifyJwtReplyNamespace<C>maintains complete backwards compatibility for existing codebases. - Cleanly addresses #321 by allowing users to augment
FastifyRequestandFastifyReplyindependently without pollutingFastifyInstance. - Fallback logic for custom method keys (
jwtDecode,jwtVerify,jwtSign) behaves as expected when only a subset of method names are overridden. - All 15 CI matrix jobs across Node 20 through Node 26 (Ubuntu, macOS, Windows) and
tstycheassertions pass cleanly.
This branch has not been deployed
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.
Fixes #321.
Problem
When registering the plugin with the
namespaceoption (e.g.namespace: 'auth'), runtime decorators are registered onFastifyRequest(request.authJwtVerify,request.authJwtDecode) andFastifyReply(reply.authJwtSign).However, the documentation and type definitions provided only
FastifyJwtNamespace, a union type merging both request and reply functions, and instructed users to extendFastifyInstance:This caused:
FastifyInstanceincorrectly receiving request/reply methods.FastifyRequestandFastifyReplynot receiving their respective decorator typings, making calls likerequest.authJwtVerify()orreply.authJwtSign()fail TypeScript compilation.Fix
FastifyJwtRequestNamespaceandFastifyJwtReplyNamespacehelper types scoped specifically to request and reply interfaces.FastifyJwtNamespaceas an intersection of both helpers for backwards compatibility.README.mddocumenting the correct augmentation pattern forFastifyRequestandFastifyReply.types/namespace.tst.tsasserting thatrequest.authJwtVerify,request.authJwtDecode, andreply.authJwtSignare properly typed.Checklist
npm test— lint clean, 199/199 unit tests (100% coverage), 49/49 type assertions