TypeScript/tests/cases/compiler/contextualTypingOfTooShortOverloads.ts
Nathan Shively-Sanders cff586d4ad Test skip overloads w/too-short function params
1. Update changed baseline.
2. Add a new test with baseline.
2016-10-27 14:44:54 -07:00

50 lines
1.1 KiB
TypeScript

// small repro from #11875
var use: Overload;
use((req, res) => {});
interface Overload {
(handler1: (req1: string) => void): void;
(handler2: (req2: number, res2: number) => void): void;
}
// larger repro from #11875
let app: MyApp;
app.use((err: any, req, res, next) => { return; });
interface MyApp {
use: IRouterHandler<this> & IRouterMatcher<this>;
}
interface IRouterHandler<T> {
(...handlers: RequestHandler[]): T;
(...handlers: RequestHandlerParams[]): T;
}
interface IRouterMatcher<T> {
(path: PathParams, ...handlers: RequestHandler[]): T;
(path: PathParams, ...handlers: RequestHandlerParams[]): T;
}
type PathParams = string | RegExp | (string | RegExp)[];
type RequestHandlerParams = RequestHandler | ErrorRequestHandler | (RequestHandler | ErrorRequestHandler)[];
interface RequestHandler {
(req: Request, res: Response, next: NextFunction): any;
}
interface ErrorRequestHandler {
(err: any, req: Request, res: Response, next: NextFunction): any;
}
interface Request {
method: string;
}
interface Response {
statusCode: number;
}
interface NextFunction {
(err?: any): void;
}