Title: Issue with mapped types and enums · Issue #17288 · microsoft/TypeScript · GitHub
Open Graph Title: Issue with mapped types and enums · Issue #17288 · microsoft/TypeScript
X Title: Issue with mapped types and enums · Issue #17288 · microsoft/TypeScript
Description: TypeScript Version: 2.4.1 / Code enum Things { ONE = "one", TWO = "two" } type ThingMap = { [TKey in Things]: any }; const thingMap: ThingMap = { one: null, two: null }; function setThing(thing: Things, something: any) { thingMap[thing] ...
Open Graph Description: TypeScript Version: 2.4.1 / Code enum Things { ONE = "one", TWO = "two" } type ThingMap = { [TKey in Things]: any }; const thingMap: ThingMap = { one: null, two: null }; function setThing(thing: Th...
X Description: TypeScript Version: 2.4.1 / Code enum Things { ONE = "one", TWO = "two" } type ThingMap = { [TKey in Things]: any }; const thingMap: ThingMap = { one: null, two: null }; functio...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/17288
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Issue with mapped types and enums","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.1 /\r\n\r\n**Code**\r\n\r\n```ts\r\nenum Things {\r\n\tONE = \"one\",\r\n\tTWO = \"two\"\r\n}\r\n\r\ntype ThingMap = { [TKey in Things]: any };\r\n\r\nconst thingMap: ThingMap = {\r\n\tone: null,\r\n\ttwo: null\r\n};\r\n\r\nfunction setThing(thing: Things, something: any) {\r\n\tthingMap[thing] = something;\r\n}\r\n\r\n```\r\n\r\n**Expected behavior:**\r\nJust like I can do `thingMap[Things.ONE] = 'blah'` without any errors, this should not throw an error.\r\n**Actual behavior:**\r\nsrc/test.ts(14,2): error TS7017: Element implicitly has an 'any' type because type 'ThingMap' has no index signature.","author":{"url":"https://github.com/blocka","@type":"Person","name":"blocka"},"datePublished":"2017-07-19T09:23:17Z","url":"https://github.com/microsoft/TypeScript/issues/17288"}
| 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:64f8b432-101d-c96e-64aa-9405895e81f9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD12:163142:29CE01:3B7A99:6B046B3E |
| html-safe-nonce | 36090265f17208080b22dd215d5386e47a070ab80ffec63130577f62e3be96ad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDEyOjE2MzE0MjoyOUNFMDE6M0I3QTk5OjZCMDQ2QjNFIiwidmlzaXRvcl9pZCI6IjcxMTk3NzQ4OTQ3NjE3MzI5MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f77a29c0b2bf3986e1418d804d72bc22bc8cf4b32c3353dc0fb162c551e028a9 |
| hovercard-subject-tag | issue:243976352 |
| 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/17288/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f66525fd626cb98d6f2b2fcbab08452b684c3c7608bc30816ba54fea5276fc65/microsoft/TypeScript/issues/17288 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f66525fd626cb98d6f2b2fcbab08452b684c3c7608bc30816ba54fea5276fc65/microsoft/TypeScript/issues/17288 |
| og:image:alt | TypeScript Version: 2.4.1 / Code enum Things { ONE = "one", TWO = "two" } type ThingMap = { [TKey in Things]: any }; const thingMap: ThingMap = { one: null, two: null }; function setThing(thing: Th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | blocka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f |
| 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 | ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width