Title: Misleading error elaboration · Issue #25971 · microsoft/TypeScript · GitHub
Open Graph Title: Misleading error elaboration · Issue #25971 · microsoft/TypeScript
X Title: Misleading error elaboration · Issue #25971 · microsoft/TypeScript
Description: TypeScript Version: 3.1.0-dev Search Terms: Error elaboration Code function foo
Open Graph Description: TypeScript Version: 3.1.0-dev Search Terms: Error elaboration Code function foo
X Description: TypeScript Version: 3.1.0-dev Search Terms: Error elaboration Code function foo<T extends { a: string }>(x: T) { x = { a: "abc", b: 20, c: 30 }; } Expected behavior: An error statin...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/25971
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Misleading error elaboration","articleBody":"**TypeScript Version:** 3.1.0-dev\r\n\r\n**Search Terms:** Error elaboration\r\n\r\n**Code**\r\n\r\n```ts\r\nfunction foo\u003cT extends { a: string }>(x: T) {\r\n x = { a: \"abc\", b: 20, c: 30 };\r\n}\r\n```\r\n\r\n**Expected behavior:** An error stating `{ a: string, b: number, c: number }` is not assignable to `T`.\r\n\r\n**Actual behavior:** Elaboration errors on the `b` and `c` property assignments which misleads the user to think the issue is with those properties. The real issue is that *no* object literal and *only* a `T` is assignable to `T`, and we should not attempt to elaborate here. Generally, the elaboration logic can't rely on the behavior of `getIndexedAccess` without first validating that a meaningful type is being requested because `getIndexedAccess` will happily create deferred indexed access types that technically are errors. The elaboration logic needs to be more selective about which target types it descends into. Specifically, I would suggest only descending into non-generic object types and non-generic intersection types.","author":{"url":"https://github.com/ahejlsberg","@type":"Person","name":"ahejlsberg"},"datePublished":"2018-07-26T14:19:12Z","url":"https://github.com/microsoft/TypeScript/issues/25971"}
| 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:d754f81a-f5b7-0add-071f-92cc83d991ff |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8206:291B58:19943A:208027:6B00FB79 |
| html-safe-nonce | 149f9e41c5d342df390f8c06bdd32051a70f666bba3a3f9bf302c9d96c4404a9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjA2OjI5MUI1ODoxOTk0M0E6MjA4MDI3OjZCMDBGQjc5IiwidmlzaXRvcl9pZCI6IjU4NjE4OTQ3NTMxOTY1MDU5NzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 92353ba8feeac39b82c0b1cdfe90ed1408de9d1355db04738014dc388bb1255f |
| hovercard-subject-tag | issue:344864580 |
| 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/25971/issue_layout |
| twitter:image | https://opengraph.githubassets.com/53dc8075043a4c08b7edcfccc4be5e478f96753457e6e4a4c7dac85b3ef8fef9/microsoft/TypeScript/issues/25971 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/53dc8075043a4c08b7edcfccc4be5e478f96753457e6e4a4c7dac85b3ef8fef9/microsoft/TypeScript/issues/25971 |
| og:image:alt | TypeScript Version: 3.1.0-dev Search Terms: Error elaboration Code function foo |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ahejlsberg |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| 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 | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width