Open jabinb opened 1 year ago
thank you! could you send a pr for this?
Yep, no worries, will submit one shortly.
@kibertoad I've had a look at it, it seems like there's something deeper going on with the way the types are being merged as updating RouteHandlerMethod
's signature to mirror upstreams still forces the type provider to be FastifyTypeProviderDefault
.
You can see an example at this playground.
I think it may be because upstream RouteHandlerMethod
is a type
not an interface
so you shouldn't be able to use an interface
to merge with it, however in the playground example above the FunkyReply
return type restriction still works :man_shrugging:
I'm not too familiar with fastify's type structure but maybe there's another target that can be used to restrict the handler return types?
Prerequisites
Fastify version
4.12.0
Plugin version
3.0.0
Node.js version
16.14.2
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
22.04
Description
The
RouteHandlerMethod
override added in #50 omits the last three generic parameters (SchemaCompiler
,TypeProvider
andLogger
) likely because it was made prior to https://github.com/fastify/fastify/pull/3398This restricts the TypeProvider type to always be
FastifyTypeProviderDefault
resulting in all schema types beingunknown
Steps to Reproduce
I've made a Typescript Playground where you can test out the issue.
Expected Behavior
The type provider declared by
withTypeProvider
should be used in the route handler.