Skip to content

Commit

Permalink
chore(type): Add enterWith decorator (#9)
Browse files Browse the repository at this point in the history
* chore(type): Add enterwith decorator

* Update dependency

* Dev dependency
  • Loading branch information
rozzilla authored Apr 24, 2024
1 parent 3ef4dd0 commit 26917b6
Show file tree
Hide file tree
Showing 3 changed files with 9 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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"homepage": "https://github.com/mcollina/fastify-asyncforge#readme",
"devDependencies": {
"@matteo.collina/tspl": "^0.1.1",
"@types/node": "^20.12.7",
"borp": "^0.11.0",
"fastify": "^4.26.2",
"standard": "^17.1.0",
Expand Down

0 comments on commit 26917b6

Please sign in to comment.