fastify-formbody
fastify-formbody copied to clipboard
Argument of type FastifyPluginCallback<...> is not assignable to parameter of type FastifyPluginCallback<...>
Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.5.3
Plugin version
7.1.0
Node.js version
v16.16.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.5
Description
Registering imported FastifyFormbody to Fastify instance gives casting errors.
Here full casting error:
No overload matches this call.
Overload 1 of 3, '(plugin: FastifyPluginCallback<FormBodyPluginOptions, Server, FastifyTypeProvider>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'FastifyPluginCallback<FormBodyPluginOptions, Server, FastifyTypeProviderDefault>' is not assignable to parameter of type 'FastifyPluginCallback<FormBodyPluginOptions, Server, FastifyTypeProvider>'.
Types of parameters 'instance' and 'instance' are incompatible.
Type 'FastifyInstance<Server, IncomingMessage, ServerResponse, FastifyBaseLogger, FastifyTypeProvider>' is not assignable to type 'FastifyInstance<Server, IncomingMessage, ServerResponse, FastifyLoggerInstance, FastifyTypeProviderDefault>'.
Types of property 'log' are incompatible.
Type 'FastifyBaseLogger' is not assignable to type 'FastifyLoggerInstance'.
Type 'FastifyBaseLogger' is missing the following properties from type 'LoggerExtras<LoggerOptions>': version, levels, useLevelLabels, customLevels, and 21 more.
Overload 2 of 3, '(plugin: FastifyPluginAsync<FormBodyPluginOptions, Server, FastifyTypeProvider>, opts?: FastifyRegisterOptions<FormBodyPluginOptions> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'FastifyPluginCallback<FormBodyPluginOptions, Server, FastifyTypeProviderDefault>' is not assignable to parameter of type 'FastifyPluginAsync<FormBodyPluginOptions, Server, FastifyTypeProvider>'.
Overload 3 of 3, '(plugin: FastifyPluginCallback<FormBodyPluginOptions, Server, FastifyTypeProvider> | FastifyPluginAsync<FormBodyPluginOptions, Server, FastifyTypeProvider> | Promise<...> | Promise<...>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'FastifyPluginCallback<FormBodyPluginOptions, Server, FastifyTypeProviderDefault>' is not assignable to parameter of type 'FastifyPluginCallback<FormBodyPluginOptions, Server, FastifyTypeProvider> | FastifyPluginAsync<FormBodyPluginOptions, Server, FastifyTypeProvider> | Promise<...> | Promise<...>'.
Type 'FastifyPluginCallback<FormBodyPluginOptions, Server, FastifyTypeProviderDefault>' is not assignable to type 'FastifyPluginCallback<FormBodyPluginOptions, Server, FastifyTypeProvider>'.ts(2769)
Steps to Reproduce
import FastifyFormbody from '@fastify/formbody'
// Casting error occurs here server.register(FastifyFormbody)
Expected Behavior
No casting error should occur, it should be exactly compatible types.
just for my curiosity:
Did you install @types/node?
Yes, for sure. It is installed: "@types/node": "^16.11.4"
Also tried latest one: "@types/node": "^18.7.15"
And same error persists.
Can you please provide a minimal viable code example? Like a repo which i can checkout?
It's not an actual type mismatch but causing because of package versions mismatch. Types are matching in a lite sandbox. So, I've realized that it's a yarn version management issue between multiple workspaces. When we upgrade all workspace to be same version, issue is resolved by itself. Thanks for your attention.