Skip to content

Commit

Permalink
refactor: allow ErrorConstructor constructor type for customError
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-michelet committed Jun 29, 2024
1 parent 4d311d6 commit dd189ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ declare namespace fastifyUnderPressure {
pressureHandler?: (request: FastifyRequest, reply: FastifyReply, type: string, value: number | undefined) => Promise<void> | void;
sampleInterval?: number;
exposeStatusRoute?: boolean | string | { routeOpts: object; routeSchemaOpts?: object; routeResponseSchemaOpts?: object; url?: string };
customError?: Error;
customError?: Error | ErrorConstructor;
}

export const TYPE_EVENT_LOOP_DELAY = 'eventLoopDelay'
Expand Down
4 changes: 4 additions & 0 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ const server = fastify();
server.register(fastifyUnderPressure, {
customError: new Error('custom error message')
});

server.register(fastifyUnderPressure, {
customError: Error
});
};

expectType<'eventLoopDelay'>(fastifyUnderPressure.TYPE_EVENT_LOOP_DELAY)
Expand Down

0 comments on commit dd189ce

Please sign in to comment.