Skip to content

Commit

Permalink
fix(types): Add plugin function definition
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Bianchi <[email protected]>
  • Loading branch information
rozzilla committed Apr 22, 2024
1 parent 53456d1 commit 4b3967b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
type FastifyBaseLogger,
type FastifyReply,
type FastifyRequest,
type FastifyPluginCallback,
} from "fastify";

declare namespace fastifyasyncforge {
Expand All @@ -12,4 +13,5 @@ declare namespace fastifyasyncforge {
export function logger<T extends FastifyBaseLogger>(): T;
}

declare function fastifyasyncforge(): FastifyPluginCallback;
export = fastifyasyncforge;
5 changes: 4 additions & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { expectAssignable, expectError, expectType } from "tsd";
import { app, logger, reply, request } from ".";
import fastifyasyncforge, { app, logger, reply, request } from ".";
import fastify, {
type FastifyInstance,
type FastifyBaseLogger,
type FastifyRequest,
type FastifyReply,
type RawServerDefault,
type RouteGenericInterface,
type FastifyPluginCallback,
} from "fastify";

const fastifyInstance = fastify();
expectAssignable<FastifyInstance>(fastifyInstance.register(fastifyasyncforge));
expectAssignable<FastifyPluginCallback>(fastifyasyncforge);

// app
expectAssignable<FastifyInstance>(fastifyInstance);
Expand Down

0 comments on commit 4b3967b

Please sign in to comment.