Skip to content

Commit

Permalink
Tmp: testing with supported Promise using augmentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Bocharova committed Sep 10, 2024
1 parent 78e9c0f commit e2751aa
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/express5.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @fileOverview Temporary adjustment to the Express 5 type declarations
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/69846/files#diff-5962769e8693df44c9e1083881fb1da149a67262026db939b7430536d514e7af
* */
/* eslint-disable allowed/dependencies -- this is DTS */
/* eslint-disable @typescript-eslint/no-explicit-any -- copying as is */
import { ParsedQs } from "qs";
import {
NextFunction,
ParamsDictionary,
Request,
Response,
} from "express-serve-static-core";

declare module "express-serve-static-core" {
export interface RequestHandler<
P = ParamsDictionary,
ResBody = any,
ReqBody = any,
ReqQuery = ParsedQs,
LocalsObj extends Record<string, any> = Record<string, any>,
> {
(
req: Request<P, ResBody, ReqBody, ReqQuery, LocalsObj>,
res: Response<ResBody, LocalsObj>,
next: NextFunction,
): void | Promise<void>;
}

export type ErrorRequestHandler<
P = ParamsDictionary,
ResBody = any,
ReqBody = any,
ReqQuery = ParsedQs,
LocalsObj extends Record<string, any> = Record<string, any>,
> = (
err: any,
req: Request<P, ResBody, ReqBody, ReqQuery, LocalsObj>,
res: Response<ResBody, LocalsObj>,
next: NextFunction,
) => void | Promise<void>;
}

0 comments on commit e2751aa

Please sign in to comment.