Skip to content

Commit

Permalink
Update types of fastify instance and plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30-st committed Oct 4, 2024
1 parent eb05160 commit 649f42f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
6 changes: 5 additions & 1 deletion lib/build/framework/fastify/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// @ts-nocheck
export type { SessionRequest } from "./framework";
export declare const plugin: import("./types").FastifyPluginCallback;
export declare const plugin: import("./types").FastifyPluginCallback<import("./types").FastifyInstance<
unknown,
import("./types").FastifyRequest,
import("./types").FastifyReply
>>;
export declare const errorHandler: () => (
err: any,
req: import("./types").FastifyRequest,
Expand Down
14 changes: 11 additions & 3 deletions lib/build/framework/fastify/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ export interface FastifyReply {
getHeader(key: any): number | string | string[] | undefined;
type(contentType: string): FastifyReply;
}
export interface FastifyInstance<Instance = any, Request = any, Reply = any> {
addHook(name: string, hook: (req: Request, reply: Reply) => void): Instance;
export interface FastifyInstance<
Instance = unknown,
Request extends FastifyRequest = FastifyRequest,
Reply extends FastifyReply = FastifyReply
> {
addHook(this: Instance, name: string, hook: (req: Request, reply: Reply) => void): Instance;
}
export declare type FastifyPluginCallback = (instance: any, opts: any, done: (err?: Error) => void) => void;
export declare type FastifyPluginCallback<Instance = FastifyInstance> = (
instance: Instance,
opts: unknown,
done: (err?: Error) => void
) => void;
14 changes: 11 additions & 3 deletions lib/ts/framework/fastify/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ export interface FastifyReply {
type(contentType: string): FastifyReply;
}

export interface FastifyInstance<Instance = any, Request = any, Reply = any> {
addHook(name: string, hook: (req: Request, reply: Reply) => void): Instance;
export interface FastifyInstance<
Instance = unknown,
Request extends FastifyRequest = FastifyRequest,
Reply extends FastifyReply = FastifyReply
> {
addHook(this: Instance, name: string, hook: (req: Request, reply: Reply) => void): Instance;
}

export type FastifyPluginCallback = (instance: any, opts: any, done: (err?: Error) => void) => void;
export type FastifyPluginCallback<Instance = FastifyInstance> = (
instance: Instance,
opts: unknown,
done: (err?: Error) => void
) => void;

0 comments on commit 649f42f

Please sign in to comment.