{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5254","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5254/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5254/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5254/events","html_url":"https://github.com/Microsoft/TypeScript/issues/5254","id":111439194,"number":5254,"title":"Type inference defaults to '{}'","user":{"login":"drarmstr","id":4674792,"avatar_url":"https://avatars.githubusercontent.com/u/4674792?v=3","gravatar_id":"","url":"https://api.github.com/users/drarmstr","html_url":"https://github.com/drarmstr","followers_url":"https://api.github.com/users/drarmstr/followers","following_url":"https://api.github.com/users/drarmstr/following{/other_user}","gists_url":"https://api.github.com/users/drarmstr/gists{/gist_id}","starred_url":"https://api.github.com/users/drarmstr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drarmstr/subscriptions","organizations_url":"https://api.github.com/users/drarmstr/orgs","repos_url":"https://api.github.com/users/drarmstr/repos","events_url":"https://api.github.com/users/drarmstr/events{/privacy}","received_events_url":"https://api.github.com/users/drarmstr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-14T16:40:00Z","updated_at":"2015-10-14T16:54:48Z","closed_at":null,"body":"I'm using TypeScript 1.6.3 in Visual Studio 2015.  The es6-promise declaration I'm using contains:\r\n\r\n    declare class Promise<R> implements Thenable<R> {\r\n        constructor(callback: (resolve : (value?: R | Thenable<R>) => void, reject: (error?: any) => void) => void);\r\n        then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Promise<U>;\r\n    }\r\n\r\nThe following works with an explicit typing of the Promise generic:\r\n\r\n    new Promise < { foo: number }>((resolve) => {\r\n        resolve({ foo: 1 });\r\n    }).then((value) => {\r\n        value.foo;\r\n    });\r\n\r\nHowever, shouldn't type inference allow the following to work?\r\n\r\n    new Promise((resolve) => {\r\n        resolve({ foo: 1 });\r\n    }).then((value) => {\r\n        value.foo;\r\n    });\r\n\r\nInstead, I am getting an error when accessing value.foo that foo does not exist on type '{}'.  Why is TypeScript defaulting to the `{}` type?"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/148115089","html_url":"https://github.com/Microsoft/TypeScript/issues/5254#issuecomment-148115089","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5254","id":148115089,"user":{"login":"RyanCavanaugh","id":6685088,"avatar_url":"https://avatars.githubusercontent.com/u/6685088?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanCavanaugh","html_url":"https://github.com/RyanCavanaugh","followers_url":"https://api.github.com/users/RyanCavanaugh/followers","following_url":"https://api.github.com/users/RyanCavanaugh/following{/other_user}","gists_url":"https://api.github.com/users/RyanCavanaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanCavanaugh/subscriptions","organizations_url":"https://api.github.com/users/RyanCavanaugh/orgs","repos_url":"https://api.github.com/users/RyanCavanaugh/repos","events_url":"https://api.github.com/users/RyanCavanaugh/events{/privacy}","received_events_url":"https://api.github.com/users/RyanCavanaugh/received_events","type":"User","site_admin":false},"created_at":"2015-10-14T16:54:47Z","updated_at":"2015-10-14T16:54:47Z","body":"`{}` is the type that appears when there are no inference sources during generic type inference. We don't do any inference from call sites, which is the only place where the type `{ foo: number }` appears in the second example."}}