NestJS:类型 'NestFastifyApplication' 不满足约束条件 'INestApplication'

NestJS: Type 'NestFastifyApplication' does not satisfy the constraint 'INestApplication'

我正在使用 NestJS 构建一个后端应用程序,我正在尝试使用 fastify 而不是 express 作为底层框架。我正在按照文档 (available here) 使用 fastify,但是我遇到了以下类型问题:

Type 'NestFastifyApplication' does not satisfy the constraint 'INestApplication'.

Type 'NestFastifyApplication' is missing the following properties from type
'INestApplication': use, enableCors, enableVersioning, listenAsync, and 22 more

这里是代码:

import { NestFactory } from '@nestjs/core';
import {
  FastifyAdapter,
  NestFastifyApplication,
} from '@nestjs/platform-fastify';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter(),
  );
  await app.listen(3001);
}
bootstrap();

问题很简单。安装 @nestjs/platform-fastify 期间出现问题。只需删除并安装软件包即可解决