Skip to content

Commit be4e50f

Browse files
fix(platform-fastify): fix register method signature types
1 parent 6f5ef69 commit be4e50f

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

packages/platform-fastify/adapters/fastify-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export class FastifyAdapter<
188188
return (this.instance as unknown) as T;
189189
}
190190

191-
public register<Options extends FastifyPluginOptions>(
191+
public register<Options extends FastifyPluginOptions = any>(
192192
plugin:
193193
| FastifyPluginCallback<Options>
194194
| FastifyPluginAsync<Options>

packages/platform-fastify/interfaces/nest-fastify-application.interface.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
11
import { INestApplication } from '@nestjs/common';
22
import {
3-
FastifyPlugin,
3+
FastifyInstance,
4+
FastifyPluginAsync,
5+
FastifyPluginCallback,
46
FastifyPluginOptions,
57
FastifyRegisterOptions,
68
} from 'fastify';
79
import {
10+
Chain as LightMyRequestChain,
811
InjectOptions,
912
Response as LightMyRequestResponse,
10-
Chain as LightMyRequestChain,
1113
} from 'light-my-request';
1214
import { FastifyStaticOptions, PointOfViewOptions } from './external';
1315

1416
export interface NestFastifyApplication extends INestApplication {
1517
/**
1618
* A wrapper function around native `fastify.register()` method.
17-
* Example `app.register(require('fastify-formbody'))`
18-
*
19-
* @returns {this}
19+
* Example `app.register(require('fastify-formbody'))
20+
* @returns {Promise<FastifyInstance>}
2021
*/
21-
register<Options extends FastifyPluginOptions>(
22-
plugin: FastifyPlugin<Options>,
22+
register<Options extends FastifyPluginOptions = any>(
23+
plugin:
24+
| FastifyPluginCallback<Options>
25+
| FastifyPluginAsync<Options>
26+
| Promise<{ default: FastifyPluginCallback<Options> }>
27+
| Promise<{ default: FastifyPluginAsync<Options> }>,
2328
opts?: FastifyRegisterOptions<Options>,
24-
): this;
29+
): Promise<FastifyInstance>;
2530

2631
/**
2732
* Sets a base directory for public assets.
2833
* Example `app.useStaticAssets({ root: 'public' })`
29-
*
3034
* @returns {this}
3135
*/
3236
useStaticAssets(options: FastifyStaticOptions): this;

0 commit comments

Comments
 (0)