From e70407f10444b9bfd009f10a09f22ef37277e686 Mon Sep 17 00:00:00 2001 From: Gleb Date: Sun, 15 Jun 2025 13:54:42 +0300 Subject: [PATCH] Fix: Correct AsyncLocalStorage type parameter to match actual store (RequestContextData) The AsyncLocalStorage was incorrectly typed as RequestContext, but in reality it stores RequestContextData, which is directly accessed via key-value operations (e.g. store[key]). Signed-off-by: Gleb --- types/index.d.ts | 2 +- types/index.test-d.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 303cedc..9b4425a 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -54,7 +54,7 @@ declare namespace fastifyRequestContext { } export const requestContext: RequestContext - export const asyncLocalStorage: AsyncLocalStorage + export const asyncLocalStorage: AsyncLocalStorage /** * @deprecated Use FastifyRequestContextOptions instead */ diff --git a/types/index.test-d.ts b/types/index.test-d.ts index 0f62272..62e4d4d 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -5,6 +5,7 @@ import { FastifyRequestContextOptions, RequestContext, RequestContextDataFactory, + RequestContextData, } from '..' import { expectAssignable, expectType, expectError } from 'tsd' import { FastifyBaseLogger, FastifyInstance, RouteHandlerMethod } from 'fastify' @@ -63,7 +64,7 @@ expectError(() => ({ log: 'dummy' })) expectType(app.requestContext) expectType(requestContext) -expectType>(asyncLocalStorage) +expectType>(asyncLocalStorage) const getHandler: RouteHandlerMethod = function (request, _reply) { expectType(request.requestContext)