{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11875","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11875/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11875/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11875/events","html_url":"https://github.com/Microsoft/TypeScript/issues/11875","id":185550165,"number":11875,"title":"express.d.ts simple usage broken in latest bits","user":{"login":"billti","id":993909,"avatar_url":"https://avatars.githubusercontent.com/u/993909?v=3","gravatar_id":"","url":"https://api.github.com/users/billti","html_url":"https://github.com/billti","followers_url":"https://api.github.com/users/billti/followers","following_url":"https://api.github.com/users/billti/following{/other_user}","gists_url":"https://api.github.com/users/billti/gists{/gist_id}","starred_url":"https://api.github.com/users/billti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/billti/subscriptions","organizations_url":"https://api.github.com/users/billti/orgs","repos_url":"https://api.github.com/users/billti/repos","events_url":"https://api.github.com/users/billti/events{/privacy}","received_events_url":"https://api.github.com/users/billti/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Bug","name":"Bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/20","html_url":"https://github.com/Microsoft/TypeScript/milestones/TypeScript%202.1","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/20/labels","id":1601840,"number":20,"title":"TypeScript 2.1","description":"","creator":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.githubusercontent.com/u/8000722?v=3","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"open_issues":55,"closed_issues":224,"state":"open","created_at":"2016-02-24T06:32:42Z","updated_at":"2016-10-27T01:15:06Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2016-10-27T01:14:39Z","updated_at":"2016-10-27T10:11:33Z","closed_at":null,"body":"A basic Express 4 sample has errors with the latest bits. It appears to be a regression in TypeScript 2.1.\r\n\r\nBelow is how far I’ve managed to reduce the code into a standalone repro before heading home (from the definition currently in @types/express).\r\n\r\nIf I compile with the current bits in the “release-2.0.5” branch there is no error. This is specific to what is currently in “release-2.1”.\r\n\r\n\r\n```\r\nseverity: 'Error'\r\nmessage: 'Argument of type '(err: any, req: Response, res: NextFunction, next: any) => void' is not assignable to parameter of type 'PathParams'.\r\n  Type '(err: any, req: Response, res: NextFunction, next: any) => void' is not assignable to type '(string | RegExp)[]'.\r\n    Property 'push' is missing in type '(err: any, req: Response, res: NextFunction, next: any) => void'.'\r\n```\r\n\r\n```typescript\r\nvar app: myApp;\r\n\r\napp.use((err: any, req, res, next) => { return; }); // <--- error on this call to 'use'\r\n\r\n\r\ninterface myApp {\r\n    use: IRouterHandler<this> & IRouterMatcher<this>;\r\n}\r\n        \r\n    interface IRouterHandler<T> {\r\n        (...handlers: RequestHandler[]): T;\r\n        (...handlers: RequestHandlerParams[]): T;\r\n    }\r\n    \r\n    interface IRouterMatcher<T> {\r\n        (path: PathParams, ...handlers: RequestHandler[]): T;\r\n        (path: PathParams, ...handlers: RequestHandlerParams[]): T;\r\n    }\r\n\r\n    type PathParams = string | RegExp | (string | RegExp)[];\r\n    type RequestHandlerParams = RequestHandler | ErrorRequestHandler | (RequestHandler | ErrorRequestHandler)[];\r\n\r\n    interface RequestHandler {\r\n        (req: Request, res: Response, next: NextFunction): any;\r\n    }\r\n\r\n    interface ErrorRequestHandler {\r\n        (err: any, req: Request, res: Response, next: NextFunction): any;\r\n    }\r\n\r\n    interface Request {\r\n        method: string;\r\n    }\r\n\r\n    interface Response {\r\n        statusCode: number;\r\n    }\r\n\r\n    interface NextFunction {\r\n        (err?: any): void;\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/256602071","html_url":"https://github.com/Microsoft/TypeScript/issues/11875#issuecomment-256602071","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11875","id":256602071,"user":{"login":"HerringtonDarkholme","id":2883231,"avatar_url":"https://avatars.githubusercontent.com/u/2883231?v=3","gravatar_id":"","url":"https://api.github.com/users/HerringtonDarkholme","html_url":"https://github.com/HerringtonDarkholme","followers_url":"https://api.github.com/users/HerringtonDarkholme/followers","following_url":"https://api.github.com/users/HerringtonDarkholme/following{/other_user}","gists_url":"https://api.github.com/users/HerringtonDarkholme/gists{/gist_id}","starred_url":"https://api.github.com/users/HerringtonDarkholme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HerringtonDarkholme/subscriptions","organizations_url":"https://api.github.com/users/HerringtonDarkholme/orgs","repos_url":"https://api.github.com/users/HerringtonDarkholme/repos","events_url":"https://api.github.com/users/HerringtonDarkholme/events{/privacy}","received_events_url":"https://api.github.com/users/HerringtonDarkholme/received_events","type":"User","site_admin":false},"created_at":"2016-10-27T10:11:32Z","updated_at":"2016-10-27T10:11:32Z","body":"```typescript\r\nfunction checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, contextualMapper?: TypeMapper): Type {\r\n  // omitted....\r\n\r\n  if (mightFixTypeParameters || !(links.flags & NodeCheckFlags.ContextChecked)) {\r\n    const contextualSignature = getContextualSignature(node);\r\n    const contextChecked = !!(links.flags & NodeCheckFlags.ContextChecked);\r\n    if (mightFixTypeParameters || !contextChecked) {\r\n      links.flags |= NodeCheckFlags.ContextChecked;\r\n      if (contextualSignature) {\r\n        const signature = getSignaturesOfType(type, SignatureKind.Call)[0];  // <- problem here\r\n        if (contextSensitive) {\r\n          assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper);\r\n        }\r\n```\r\n\r\nThe `signature` is the first one in overloaded function. Before 8094b2c `contextSensitive` is true only when no parameter is annotated, so the overload will always succeed. It's no longer true after partial annotation inference... \r\n\r\n@ahejlsberg @sandersn Any idea about fixing this?\r\n\r\nI have thought about 1. give up contextual typing if in an overloaded call, or 2. reassign contextual parameter types in `chooseOverload`. "}}
{"actor":{"display_login":"HerringtonDarkholme"}}