Skip to content

Commit 2f4f5f5

Browse files
rozzillamcollina
andauthored
fix(types): Request route options url add undefined (fastify#5307)
* fix(types): Request route options url add undefined * Add test Signed-off-by: Roberto Bianchi <[email protected]> --------- Signed-off-by: Roberto Bianchi <[email protected]> Co-authored-by: Matteo Collina <[email protected]>
1 parent f26de5d commit 2f4f5f5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

test/types/request.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pino from 'pino'
21
import { expectAssignable, expectType } from 'tsd'
32
import fastify, {
43
ContextConfigDefault,
@@ -83,6 +82,7 @@ const getHandler: RouteHandler = function (request, _reply) {
8382
expectType<FastifySchema>(request.routeSchema)
8483
expectType<FastifySchema>(request.routeOptions.schema)
8584
expectType<RouteHandlerMethod>(request.routeOptions.handler)
85+
expectType<string | undefined>(request.routeOptions.url)
8686

8787
expectType<RequestHeadersDefault & RawRequestDefaultExpression['headers']>(request.headers)
8888
request.headers = {}

types/request.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ export interface ValidationFunction {
2222

2323
export interface RequestRouteOptions<ContextConfig = ContextConfigDefault, SchemaCompiler = FastifySchema> {
2424
method: string;
25-
url: string;
26-
bodyLimit:number;
27-
attachValidation:boolean;
28-
logLevel:string;
25+
// `url` can be `undefined` for instance when `request.is404` is true
26+
url: string | undefined;
27+
bodyLimit: number;
28+
attachValidation: boolean;
29+
logLevel: string;
2930
version: string | undefined;
3031
exposeHeadRoute: boolean;
3132
prefixTrailingSlash: string;

0 commit comments

Comments
 (0)