-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Regsiter fastify plugin doesn't work #11265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi! Looks like your repository is private. |
In my case, reverting the TypeScript version to 4.9 resolved the issue. |
Ensure that the Fastify version in the project matches the one specified in @nestjs/platform-fastify |
I have this problem in recent versions. |
Have you found any solution? |
UPDATE: I found out that the app.register function from the NestFastifyApplication is based on fastify@4.26.0 whereas @nestjs/platform-fastify seems to want to have fastify@4.26.1. They are not compatible. When I install fastify@4.26.0 I can register my plugins. @deleau-victor Maybe someone from your nestjs team can check this up? I am facing the same type incompatibility issue with the latest versions and pnpm:
Any advice? |
For now this is the solution I have found, I have the same versions as you do. Main.ts
and I had to disable this to stop slint from displaying that error, at the start of Main.ts /* eslint-disable @typescript-eslint/no-var-requires */ |
This is generally a typescript error due to the fact that |
This worked for me. Changed package.json to |
Just adding
To add more context: what's happening is that the other dependencies like |
I used a translator. The solution I found was to ignore the type checking or make the versions match. sol. 1 // @ts-ignore
await app.register(fastifyCookie); However, I have a question. Types like FastifyReply and FastifyRequest obviously exist in the Fastify package, so it makes sense to add these dependencies additionally. Due to this, compatibility issues with versions can arise, forcing me to tediously update Fastify with every release. While I gained type safety, I encountered compatibility issues. 😂 Is there a better way to alleviate this fatigue? |
Is there any elegant way now |
Thanks @joelywz. This fixed the issue for me. Adding this comment for visibility. |
Is there an existing issue for this?
Current behavior
Hi i am trying to register the fastify plugins but there are errors and i don't know why because in my previous code i was doing the same thinks and was working.
Like on this code, all registered plugins return error like :
'Argument of type 'FastifyCookie' is not assignable to parameter of type 'FastifyPluginCallback<FastifyCookieOptions, RawServerDefault, FastifyTypeProviderDefault, FastifyBaseLogger> | FastifyPluginAsync<...> | Promise<...> | Promise<...>'
Minimum reproduction code
https://github.com/deleau-victor/docchus-back
Steps to reproduce
Try to register any fastify plugin
Expected behavior
Nest JS must correctly register the fastify plugins
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
No response
Packages versions
Node.js version
No response
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: