Title: T[keyof T] assignable to T[K] · Issue #17166 · microsoft/TypeScript · GitHub
Open Graph Title: T[keyof T] assignable to T[K] · Issue #17166 · microsoft/TypeScript
X Title: T[keyof T] assignable to T[K] · Issue #17166 · microsoft/TypeScript
Description: TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Code // A *self-contained* demonstration of the problem follows... function f
Open Graph Description: TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Code // A *self-contained* demonstration of the problem follows... function f
X Description: TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Code // A *self-contained* demonstration of the problem follows... function f<T, K extends keyof T>(obj: T, k: K, value:T[K]) { for (l...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/17166
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"T[keyof T] assignable to T[K]","articleBody":"\u003c!-- BUGS: Please use this template. -->\r\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\r\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\r\n\r\n**TypeScript Version:** 2.4.0 / nightly (2.5.0-dev.201xxxxx)\r\n\r\n**Code**\r\n\r\n```ts\r\n// A *self-contained* demonstration of the problem follows...\r\nfunction f\u003cT, K extends keyof T>(obj: T, k: K, value:T[K]) {\r\n for (let key in obj) {\r\n value = obj[key];\r\n break; \r\n } \r\n return value;\r\n}\r\n\r\nf({ x: 1, y: \"\" }, 'y', \"1\").charAt(0); //runtime error\r\n\r\n```\r\n\r\n**Expected behavior:**\r\nCompiler error \r\n**Actual behavior:**\r\nRuntime error ","author":{"url":"https://github.com/olegdunkan","@type":"Person","name":"olegdunkan"},"datePublished":"2017-07-13T15:33:52Z","url":"https://github.com/microsoft/TypeScript/issues/17166"}
| 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:8d5d8d8f-3489-f57f-9e73-dc595210d7f3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B752:33444D:B84BE4:F6703A:6B00F4F5 |
| html-safe-nonce | 79158badcb9e8edb430e458fb31c84e87bf906658df3ae8f981b1bbdd735ff35 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzUyOjMzNDQ0RDpCODRCRTQ6RjY3MDNBOjZCMDBGNEY1IiwidmlzaXRvcl9pZCI6IjU3OTQwMDE4Njc2NjM1Nzc0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 23363ea0a1e8af07267593c4c70698efb01200a29051439a663426fa56eba2cc |
| hovercard-subject-tag | issue:242741997 |
| 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/17166/issue_layout |
| twitter:image | https://opengraph.githubassets.com/614fda37beaf4ae47440cd9418f7a860ab65fad8da36d77803cb217199ac009a/microsoft/TypeScript/issues/17166 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/614fda37beaf4ae47440cd9418f7a860ab65fad8da36d77803cb217199ac009a/microsoft/TypeScript/issues/17166 |
| og:image:alt | TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Code // A *self-contained* demonstration of the problem follows... function f |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | olegdunkan |
| 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