-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: fix header and body generic types #2103
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,8 +110,8 @@ const opts: fastify.RouteShorthandOptions = { | |
server.get<Query, Params, Headers, Body>('/ping/:bar', opts, (request, reply) => { | ||
console.log(request.query) // this is of type Query! | ||
console.log(request.params) // this is of type Params! | ||
console.log(request.body) // this is of type Body! | ||
console.log(request.headers) // this is of type Headers! | ||
console.log(request.body) // this is of type Body! | ||
reply.code(200).send({ pong: 'it worked!' }) | ||
}) | ||
``` | ||
|
@@ -143,8 +143,8 @@ const opts: fastify.RouteShorthandOptions = { | |
server.get<fastify.DefaultQuery, Params, unknown>('/ping/:bar', opts, (request, reply) => { | ||
console.log(request.query) // this is of type fastify.DefaultQuery! | ||
console.log(request.params) // this is of type Params! | ||
console.log(request.body) // this is of type unknown! | ||
console.log(request.headers) // this is of type fastify.DefaultHeader because typescript will use the default type value! | ||
console.log(request.headers) // this is of type unknown! | ||
console.log(request.body) // this is of type fastify.DefaultBody because typescript will use the default type value! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the easiest correction to make to be valid, however I think it does take the value of example down a bit. |
||
reply.code(200).send({ pong: 'it worked!' }) | ||
}) | ||
|
||
|
@@ -155,8 +155,8 @@ server.get<fastify.DefaultQuery, Params, unknown>('/ping/:bar', opts, (request, | |
server.get<unknown, Params, unknown, unknown>('/ping/:bar', opts, (request, reply) => { | ||
console.log(request.query) // this is of type unknown! | ||
console.log(request.params) // this is of type Params! | ||
console.log(request.body) // this is of type unknown! | ||
console.log(request.headers) // this is of type unknown! | ||
console.log(request.body) // this is of type unknown! | ||
reply.code(200).send({ pong: 'it worked!' }) | ||
}) | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These re-orders aren't required, but I think it's more clear to follow the order of types. Body being last one.