Skip to content

Commit 9cc5187

Browse files
types: Allow port to be null in request type definition (#6589)
* types: Allow port to be null in request type definition Signed-off-by: Tristan Barlow-Griffin <tristanbarlowg@gmail.com> * types: updated port expectType test to reflect the new type (number | null) --------- Signed-off-by: Tristan Barlow-Griffin <tristanbarlowg@gmail.com>
1 parent 722d83b commit 9cc5187

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

test/types/request.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const getHandler: RouteHandler = function (request, _reply) {
6868
expectType<boolean>(request.is404)
6969
expectType<string>(request.hostname)
7070
expectType<string>(request.host)
71-
expectType<number>(request.port)
71+
expectType<number | null>(request.port)
7272
expectType<string>(request.ip)
7373
expectType<string[] | undefined>(request.ips)
7474
expectType<RawRequestDefaultExpression>(request.raw)

types/request.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface FastifyRequest<RouteGeneric extends RouteGenericInterface = Rou
7474
readonly ip: string;
7575
readonly ips?: string[];
7676
readonly host: string;
77-
readonly port: number;
77+
readonly port: number | null;
7878
readonly hostname: string;
7979
readonly url: string;
8080
readonly originalUrl: string;

0 commit comments

Comments
 (0)