Title: Constraints which are generic mapped types should have a constraint of the same mapping over their generic's constraint · Issue #21249 · microsoft/TypeScript · GitHub
Open Graph Title: Constraints which are generic mapped types should have a constraint of the same mapping over their generic's constraint · Issue #21249 · microsoft/TypeScript
X Title: Constraints which are generic mapped types should have a constraint of the same mapping over their generic's constraint · Issue #21249 · microsoft/TypeScript
Description: Code function f< T extends { member: string }, TParam extends Readonly
Open Graph Description: Code function f< T extends { member: string }, TParam extends Readonly
X Description: Code function f< T extends { member: string }, TParam extends Readonly<T> >(param: TParam, mutableSet: T): TParam { const x: string = param.member; return param; } Expected behavior: Co...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/21249
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Constraints which are generic mapped types should have a constraint of the same mapping over their generic's constraint","articleBody":"**Code**\r\n\r\n```ts\r\nfunction f\u003c\r\n T extends { member: string },\r\n TParam extends Readonly\u003cT>\r\n>(param: TParam, mutableSet: T): TParam {\r\n const x: string = param.member;\r\n return param;\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nCode works\r\n\r\n**Actual behavior:**\r\nProperty `member` does not exist on type `TParam`.\r\n\r\nWhen you call `f`, you _must_ pass a first (and second) argument which provide a member named `member` (this is enforced), so it's common sense that within `f` you should always have access to the field of `TParam` named `member`. It _seems_ like the issue today is that when calculating a generic's constraint, we don't consider a mapped type's generics' constraints when calculating its constraint.\r\n","author":{"url":"https://github.com/weswigham","@type":"Person","name":"weswigham"},"datePublished":"2018-01-18T00:31:46Z","url":"https://github.com/microsoft/TypeScript/issues/21249"}
| 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:8424e34c-f0ac-7926-8a7f-992b2f45b9ed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8E0A:FC5BE:2A2BC5D:3806002:6B01BCED |
| html-safe-nonce | 06ae3950186faffaad155bbe277860c5cb66e754a98a7bca88f52a8950a9dbec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTBBOkZDNUJFOjJBMkJDNUQ6MzgwNjAwMjo2QjAxQkNFRCIsInZpc2l0b3JfaWQiOiIxMzkwOTE4MjA3MDUyODIzNzg5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 75551631e84a7911f1f5650e29661ddfa5409ad06148c59a4c064eeaa597fe95 |
| hovercard-subject-tag | issue:289463040 |
| 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/21249/issue_layout |
| twitter:image | https://opengraph.githubassets.com/989da26d31e14ae43836bd267d8c7c1bb1d7a20e7eeaac0bea4f943ac8ca3638/microsoft/TypeScript/issues/21249 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/989da26d31e14ae43836bd267d8c7c1bb1d7a20e7eeaac0bea4f943ac8ca3638/microsoft/TypeScript/issues/21249 |
| og:image:alt | Code function f< T extends { member: string }, TParam extends Readonly |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | weswigham |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width