Closed FabianFrank closed 1 year ago
Same here. My type error (censored imports):
error TS2769: No overload matches this call.
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ max: number; timeWindow: string; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'typeof import(".../node_modules/@fastify/rate-limit/types/index")' is not assignable to parameter of type 'FastifyPluginCallback<{ max: number; timeWindow: string; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'typeof import(".../node_modules/@fastify/rate-limit/types/index")' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProvider>, opts: { ...; }, done: (err?: Error | undefined) => void): void'.
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ max: number; timeWindow: string; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'typeof import(".../node_modules/@fastify/rate-limit/types/index")' is not assignable to paramet Type 'typeof import(".../node_modules/@fastify/rate-limit/types/index")' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProvider>, opts: { ...; }): Promise<...>'.
Overload 3 of 3, '(plugin: FastifyPluginCallback<{ max: number; timeWindow: string; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger> | FastifyPluginAsync<...> | Promise<...> | Promise<...>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'typeof import(".../node_modules/@fastify/rate-limit/types/index")' is not assignable to parameter of type 'FastifyPluginCallback<{ max: number; timeWindow: string; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger> | FastifyPluginAsync<...> | Promise<...> | Promise<...>'.
fastify.register(rateLimit, {
~~~~~~~~~
I didn't see the types properly set the FastifyRouteConfig
interface in this plugin.
It is correct that typescript throw error in this case.
Would you like to send PR to update the types?
@KirillTregubov For your issue, please try version 8.0.2
Would you like to send PR to update the types?
Sure, I'll take a look today
Fixed, thanks so much!
Prerequisites
Fastify version
4.19.2
Plugin version
8.0.1
Node.js version
18.16.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
Ventura 13.4.1 (22F82)
Description
Upgrading from fastify 4.18.0 to 4.19.2 results in the following type error:
Somehow the rate limit types no longer get applied to the route config options. The issues appears first with fastify 4.19.0.
Steps to Reproduce
Expected Behavior
the types should work as they do with fastify 4.18.0