Skip to content

Commit

Permalink
fix(types): Request route options url add undefined (#5307)
Browse files Browse the repository at this point in the history
* fix(types): Request route options url add undefined

* Add test

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>

---------

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
Co-authored-by: Matteo Collina <hello@matteocollina.com>
  • Loading branch information
rozzilla and mcollina committed Feb 9, 2024
1 parent f26de5d commit 2f4f5f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/types/request.test-d.ts
@@ -1,4 +1,3 @@
import pino from 'pino'
import { expectAssignable, expectType } from 'tsd'
import fastify, {
ContextConfigDefault,
Expand Down Expand Up @@ -83,6 +82,7 @@ const getHandler: RouteHandler = function (request, _reply) {
expectType<FastifySchema>(request.routeSchema)
expectType<FastifySchema>(request.routeOptions.schema)
expectType<RouteHandlerMethod>(request.routeOptions.handler)
expectType<string | undefined>(request.routeOptions.url)

expectType<RequestHeadersDefault & RawRequestDefaultExpression['headers']>(request.headers)
request.headers = {}
Expand Down
9 changes: 5 additions & 4 deletions types/request.d.ts
Expand Up @@ -22,10 +22,11 @@ export interface ValidationFunction {

export interface RequestRouteOptions<ContextConfig = ContextConfigDefault, SchemaCompiler = FastifySchema> {
method: string;
url: string;
bodyLimit:number;
attachValidation:boolean;
logLevel:string;
// `url` can be `undefined` for instance when `request.is404` is true
url: string | undefined;
bodyLimit: number;
attachValidation: boolean;
logLevel: string;
version: string | undefined;
exposeHeadRoute: boolean;
prefixTrailingSlash: string;
Expand Down

0 comments on commit 2f4f5f5

Please sign in to comment.