1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
=== tests/cases/compiler/contextualTypingOfTooShortOverloads.ts ===
// small repro from #11875
var use: Overload;
>use : Overload
use((req, res) => {});
>use((req, res) => {}) : void
>use : Overload
>(req, res) => {} : (req: any, res: any) => void
>req : any
>res : any
interface Overload {
(handler1: (req1: string) => void): void;
>handler1 : (req1: string) => void
>req1 : string
(handler2: (req2: number, res2: number) => void): void;
>handler2 : (req2: number, res2: number) => void
>req2 : number
>res2 : number
}
// larger repro from #11875
let app: MyApp;
>app : MyApp
app.use((err: any, req, res, next) => { return; });
>app.use((err: any, req, res, next) => { return; }) : MyApp
>app.use : IRouterHandler<MyApp> & IRouterMatcher<MyApp>
>app : MyApp
>use : IRouterHandler<MyApp> & IRouterMatcher<MyApp>
>(err: any, req, res, next) => { return; } : (err: any, req: any, res: any, next: any) => void
>err : any
>req : any
>res : any
>next : any
interface MyApp {
use: IRouterHandler<this> & IRouterMatcher<this>;
>use : IRouterHandler<this> & IRouterMatcher<this>
}
interface IRouterHandler<T> {
(...handlers: RequestHandler[]): T;
>handlers : RequestHandler[]
(...handlers: RequestHandlerParams[]): T;
>handlers : RequestHandlerParams[]
}
interface IRouterMatcher<T> {
(path: PathParams, ...handlers: RequestHandler[]): T;
>path : PathParams
>handlers : RequestHandler[]
(path: PathParams, ...handlers: RequestHandlerParams[]): T;
>path : PathParams
>handlers : RequestHandlerParams[]
}
type PathParams = string | RegExp | (string | RegExp)[];
>PathParams : string | RegExp | (string | RegExp)[]
type RequestHandlerParams = RequestHandler | ErrorRequestHandler | (RequestHandler | ErrorRequestHandler)[];
>RequestHandlerParams : RequestHandler | ErrorRequestHandler | (RequestHandler | ErrorRequestHandler)[]
interface RequestHandler {
(req: Request, res: Response, next: NextFunction): any;
>req : Request
>res : Response
>next : NextFunction
}
interface ErrorRequestHandler {
(err: any, req: Request, res: Response, next: NextFunction): any;
>err : any
>req : Request
>res : Response
>next : NextFunction
}
interface Request {
method: string;
>method : string
}
interface Response {
statusCode: number;
>statusCode : number
}
interface NextFunction {
(err?: any): void;
>err : any
}
|