Prerequisites
Fastify version
4.x.x
Plugin version
No response
Node.js version
20.x
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Ubuntu 22.04
Description
FastifyRequest.routeSchema might be undefined, for example if route does not exists. The type currently can't be trusted if you would try to access the schema within any hook.
I think the type here should be marked as optional
|
routeSchema: FastifySchema |
and same goes for schema in route options
Steps to Reproduce
Set up fastify with a hook like onRequest and observe schema while calling a route that has no been defined.
Expected Behavior
The type should correctly reflect runtime behavior
Prerequisites
Fastify version
4.x.x
Plugin version
No response
Node.js version
20.x
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Ubuntu 22.04
Description
FastifyRequest.routeSchemamight be undefined, for example if route does not exists. The type currently can't be trusted if you would try to access the schema within any hook.I think the type here should be marked as optional
fastify/types/request.d.ts
Line 67 in 4a35a5a
and same goes for schema in route options
fastify/types/request.d.ts
Line 34 in 4a35a5a
Steps to Reproduce
Set up fastify with a hook like
onRequestand observe schema while calling a route that has no been defined.Expected Behavior
The type should correctly reflect runtime behavior