Skip to content
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

fix(types): Request route options url add undefined #5307

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/types/request.test-d.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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