You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.17.0
Plugin version
No response
Node.js version
18
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.3.1
Description
I'm using TypeScript and when I try to access the request's routeConfig.url TS complains about url not existing.
Looking at the types for FastifyContextConfig finds an empty interface ... is this correct? Do I have to set this manually although the url and method are built-in attributes?
Steps to Reproduce
importFastify,{FastifyRequest,FastifySchema,FastifyTypeProviderDefault,RawRequestDefaultExpression,RawServerDefault,RouteGenericInterface,}from"fastify";constfastify=Fastify({logger: false,});// TS is complaining about unknown urlfastify.addHook("onRequest",asyncfunctiononRequest(req){console.log(req.routeConfig.url);});// this works :( but I don't want to be the one telling fastify about their built-in attributesfastify.addHook("onRequest",asyncfunctiononRequest(req: FastifyRequest<RouteGenericInterface,RawServerDefault,RawRequestDefaultExpression<RawServerDefault>,FastifySchema,FastifyTypeProviderDefault,{url: string}>){console.log(req.routeConfig.url);});
// in this case req.routeConfig should know about the url attribute fastify.addHook("onRequest",asyncfunctiononRequest(req){console.log(req.routeConfig.url);});
The text was updated successfully, but these errors were encountered:
I think we never populated FastifyContextConfig with all the relevant data because this is something like an internal data structure. However, I think it's about time. Would you like to send a PR?
Prerequisites
Fastify version
4.17.0
Plugin version
No response
Node.js version
18
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.3.1
Description
I'm using TypeScript and when I try to access the request's
routeConfig.url
TS complains abouturl
not existing.Looking at the types for
FastifyContextConfig
finds an empty interface ... is this correct? Do I have to set this manually although theurl
andmethod
are built-in attributes?Steps to Reproduce
like to codesandbox: https://codesandbox.io/p/sandbox/fastify-routeconfig-url-xndp24
Expected Behavior
The text was updated successfully, but these errors were encountered: