{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3834","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3834/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3834/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3834/events","html_url":"https://github.com/Microsoft/TypeScript/issues/3834","id":94603723,"number":3834,"title":"Promise.catch should have a return type of <TResult>, not T.","user":{"login":"Zoltu","id":886059,"avatar_url":"https://avatars.githubusercontent.com/u/886059?v=3","gravatar_id":"","url":"https://api.github.com/users/Zoltu","html_url":"https://github.com/Zoltu","followers_url":"https://api.github.com/users/Zoltu/followers","following_url":"https://api.github.com/users/Zoltu/following{/other_user}","gists_url":"https://api.github.com/users/Zoltu/gists{/gist_id}","starred_url":"https://api.github.com/users/Zoltu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zoltu/subscriptions","organizations_url":"https://api.github.com/users/Zoltu/orgs","repos_url":"https://api.github.com/users/Zoltu/repos","events_url":"https://api.github.com/users/Zoltu/events{/privacy}","received_events_url":"https://api.github.com/users/Zoltu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-12T22:03:45Z","updated_at":"2015-07-13T02:38:36Z","closed_at":null,"body":"Current implementaiton:\r\n```ts\r\ninterface Promise<T> {\r\n    then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;\r\n    then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;\r\n\r\n    catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;\r\n}\r\n```\r\n\r\nWhat I believe is a more correct implementation:\r\n```ts\r\ninterface Promise<T> {\r\n    then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;\r\n    then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;\r\n\r\n    catch<TResult>(onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;\r\n    catch<TResult>(onrejected?: (reason: any) => void): Promise<TResult>;\r\n}\r\n```\r\n\r\nI believe the spec says that `catch(x)` behaves the same as `then(undefined, x)`, which implies that catch should be a generic method with a `TResult` type.\r\n\r\nIf I am misunderstanding the spec, enlightenment would be appreciated."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/120789829","html_url":"https://github.com/Microsoft/TypeScript/issues/3834#issuecomment-120789829","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3834","id":120789829,"user":{"login":"basarat","id":874898,"avatar_url":"https://avatars.githubusercontent.com/u/874898?v=3","gravatar_id":"","url":"https://api.github.com/users/basarat","html_url":"https://github.com/basarat","followers_url":"https://api.github.com/users/basarat/followers","following_url":"https://api.github.com/users/basarat/following{/other_user}","gists_url":"https://api.github.com/users/basarat/gists{/gist_id}","starred_url":"https://api.github.com/users/basarat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basarat/subscriptions","organizations_url":"https://api.github.com/users/basarat/orgs","repos_url":"https://api.github.com/users/basarat/repos","events_url":"https://api.github.com/users/basarat/events{/privacy}","received_events_url":"https://api.github.com/users/basarat/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T02:38:36Z","updated_at":"2015-07-13T02:38:36Z","body":"On second reading your suggestion isn't bad and maybe worth doing. I just wanted to point out that it is still *best effort*. "}}