nest
nest copied to clipboard
Typescript compilation error with fastify adapter
Did you read the migration guide?
- [X] I have read the whole migration guide
Is there an existing issue that is already proposing this?
- [X] I have searched the existing issues
Potential Commit/PR that introduced the regression
No response
NestJS version
10.3.0 -> 10.3.8
Describe the regression
After upgrading to the latest releases I'm getting typescript compilation errors.
This shows from and to:
[1 ~/git/koopa-api] yarn outdated
yarn outdated v1.22.22
info Color legend :
"<red>" : Major Update backward-incompatible updates
"<yellow>" : Minor Update backward-compatible features
"<green>" : Patch Update backward-compatible bug fixes
Package Current Wanted Latest Package Type URL
@nestjs/common 10.3.0 10.3.8 10.3.8 dependencies https://nestjs.com
@nestjs/core 10.3.0 10.3.8 10.3.8 dependencies https://nestjs.com
@nestjs/platform-fastify 10.0.5 10.3.8 10.3.8 dependencies https://nestjs.com
fastify 4.19.1 4.19.1 4.27.0 dependencies https://fastify.dev/
✨ Done in 4.79s.
[1 ~/git/koopa-api] yarn tsc:check
yarn run v1.22.22
$ tsc --noEmit
✨ Done in 1.56s.
[1 ~/git/koopa-api] yarn upgrade --latest @nestjs/common @nestjs/core @nestjs/platform-fastify fastify
:
✨ Done in 4.46s.
[1 ~/git/koopa-api] yarn tsc:check
yarn run v1.22.22
$ tsc --noEmit
src/app.ts:27:28 - error TS2345: Argument of type 'FastifyInstance<Server<typeof IncomingMessage, typeof ServerResponse>, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> & PromiseLike<...>' is not assignable to parameter of type 'FastifyHttp2Options<any, FastifyBaseLogger> | FastifyHttp2SecureOptions<any, FastifyBaseLogger> | FastifyHttpsOptions<...> | FastifyInstance<...> | FastifyServerOptions<...>'.
27 new FastifyAdapter(fastifyInstance),
~~~~~~~~~~~~~~~
:
The code in question is:
export async function createApp(): Promise<INestApplication> {
const fastifyInstance = fastify()
fastifyInstance.register(fastifyRequestContext, { defaultStoreValues: { localStorage: new LocalStorage() } })
fastifyInstance.addHook('onRequest', (req, reply, done) => {
requestContext.set('localStorage', new LocalStorage())
done()
})
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
/* @see https://docs.nestjs.com/techniques/performance#performance-fastify */
new FastifyAdapter(fastifyInstance),
{ bufferLogs: true },
)
return app
}
Minimum reproduction code
No response
Input code
Expected behavior
Either work as-is or some guidance on what I need to do to get it working.
Other
No response