Skip to content

Commit

Permalink
chore(type): Add enterwith decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
rozzilla committed Apr 24, 2024
1 parent 3ef4dd0 commit be5f254
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import {
type FastifyPluginCallback,
} from "fastify";

declare module "fastify" {
interface FastifyInstance {
enterWith: () => void;
}
}

declare namespace fastifyasyncforge {
export function app<T extends FastifyInstance>(): T;
export function request<T extends FastifyRequest>(): T;
Expand Down
2 changes: 2 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import fastify, {
const fastifyInstance = fastify();
expectAssignable<FastifyInstance>(fastifyInstance.register(fastifyasyncforge));
expectAssignable<FastifyPluginCallback>(fastifyasyncforge);
expectType<void>(fastifyInstance.enterWith());

// app
expectAssignable<FastifyInstance>(fastifyInstance);
expectAssignable<FastifyInstance>(app());
expectType<void>(app().enterWith());
expectAssignable<FastifyInstance>(app<FastifyInstance<RawServerDefault>>());
expectError<FastifyInstance>(app<string>());
expectError<FastifyInstance>({});
Expand Down

0 comments on commit be5f254

Please sign in to comment.