Title: Type inference defaults to '{}' in call sites. · Issue #5254 · microsoft/TypeScript · GitHub
Open Graph Title: Type inference defaults to '{}' in call sites. · Issue #5254 · microsoft/TypeScript
X Title: Type inference defaults to '{}' in call sites. · Issue #5254 · microsoft/TypeScript
Description: I'm using TypeScript 1.6.3 in Visual Studio 2015. The es6-promise declaration I'm using contains: declare class Promise
Open Graph Description: I'm using TypeScript 1.6.3 in Visual Studio 2015. The es6-promise declaration I'm using contains: declare class Promise
X Description: I'm using TypeScript 1.6.3 in Visual Studio 2015. The es6-promise declaration I'm using contains: declare class Promise<R> implements Thenable<R> { constructor(callback: (resolv...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/5254
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type inference defaults to '{}' in call sites.","articleBody":"I'm using TypeScript 1.6.3 in Visual Studio 2015. The es6-promise declaration I'm using contains:\n\n```\ndeclare class Promise\u003cR> implements Thenable\u003cR> {\n constructor(callback: (resolve : (value?: R | Thenable\u003cR>) => void, reject: (error?: any) => void) => void);\n then\u003cU>(onFulfilled?: (value: R) => U | Thenable\u003cU>, onRejected?: (error: any) => U | Thenable\u003cU>): Promise\u003cU>;\n}\n```\n\nThe following works with an explicit typing of the Promise generic:\n\n```\nnew Promise \u003c { foo: number }>((resolve) => {\n resolve({ foo: 1 });\n}).then((value) => {\n value.foo;\n});\n```\n\nHowever, shouldn't type inference allow the following to work?\n\n```\nnew Promise((resolve) => {\n resolve({ foo: 1 });\n}).then((value) => {\n value.foo;\n});\n```\n\nInstead, I am getting an error when accessing value.foo that foo does not exist on type '{}'. Why is TypeScript defaulting to the `{}` type?\n","author":{"url":"https://github.com/drarmstr","@type":"Person","name":"drarmstr"},"datePublished":"2015-10-14T16:40:00Z","url":"https://github.com/microsoft/TypeScript/issues/5254"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f92fdfa2-b4a7-7066-b95d-52fbc706afce |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AEDE:4BB79:8AF660:B2F084:6B00ECAC |
| html-safe-nonce | dbdf6b5df037ff42e9e3aba8e01e0acabb75f8ab7c28d4f4bb517253638dd59b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRURFOjRCQjc5OjhBRjY2MDpCMkYwODQ6NkIwMEVDQUMiLCJ2aXNpdG9yX2lkIjoiODQyNTg5MTM3MTY0NjI1MDE1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ccbfbc8398c0a267719b355726f8397a035e32ccec8f91a0faa61a4e5155f31a |
| hovercard-subject-tag | issue:111439194 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/5254/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a0f17d11c3b35388b44d211da7d0f60d568a2e314d1c0dcf26b6832119767e60/microsoft/TypeScript/issues/5254 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a0f17d11c3b35388b44d211da7d0f60d568a2e314d1c0dcf26b6832119767e60/microsoft/TypeScript/issues/5254 |
| og:image:alt | I'm using TypeScript 1.6.3 in Visual Studio 2015. The es6-promise declaration I'm using contains: declare class Promise |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | drarmstr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width