Title: Don't mention constraints in errors when type parameters don't explicitly specify them · Issue #33436 · microsoft/TypeScript · GitHub
Open Graph Title: Don't mention constraints in errors when type parameters don't explicitly specify them · Issue #33436 · microsoft/TypeScript
X Title: Don't mention constraints in errors when type parameters don't explicitly specify them · Issue #33436 · microsoft/TypeScript
Description: function f
Open Graph Description: function f
X Description: function f<T>(x: T) { x = {}; } Current Type '{}' is not assignable to type 'T'. '{}' is assignable to the constraint of type 'T', but 'T' could be ins...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/33436
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Don't mention constraints in errors when type parameters don't explicitly specify them","articleBody":"```\r\nfunction f\u003cT>(x: T) {\r\n x = {};\r\n}\r\n```\r\n\r\n# Current\r\n\r\n```\r\nType '{}' is not assignable to type 'T'.\r\n '{}' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.\r\n\r\nType '10' is not assignable to type 'T'.\r\n '10' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.\r\n```\r\n\r\nNobody ever mentioned a constraint or `{}` in this code, so why is it being displayed? As a user, this is telling me more than I needed or wanted to know.\r\n\r\n# Proposed\r\n\r\n```\r\nType '{}' is not assignable to type 'T'.\r\n 'T' could be instantiated with an arbitrary type which could be unrelated to '{}'.\r\n\r\n\r\nType '10' is not assignable to type 'T'.\r\n 'T' could be instantiated with an arbitrary type which could be unrelated to '10'.\r\n```","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2019-09-14T20:20:33Z","url":"https://github.com/microsoft/TypeScript/issues/33436"}
| 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:65bc9e69-9720-ded4-91f8-b0b5073f7f03 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E966:1201C:A726FF:E02260:6B00EC96 |
| html-safe-nonce | a19c46ddf4bff37065de819a754469498a6f30a9f7cf7d8c66de38a2bafcb7ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTY2OjEyMDFDOkE3MjZGRjpFMDIyNjA6NkIwMEVDOTYiLCJ2aXNpdG9yX2lkIjoiNTg3Mjk2MzkxMDQxNTQ3NzkxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | aeba14934111408f7976c17034f3ac829d63370ffb7670d3c16a0c49d1e0df4b |
| hovercard-subject-tag | issue:493662644 |
| 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/33436/issue_layout |
| twitter:image | https://opengraph.githubassets.com/640b3cffba75060293da01758b3ae47a6366e492b0ffa4700e493d1a519dfcae/microsoft/TypeScript/issues/33436 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/640b3cffba75060293da01758b3ae47a6366e492b0ffa4700e493d1a519dfcae/microsoft/TypeScript/issues/33436 |
| og:image:alt | function f |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielRosenwasser |
| 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