Title: { [key in keyof typeof Enum]: any } is not index signature · Issue #20011 · microsoft/TypeScript · GitHub
Open Graph Title: { [key in keyof typeof Enum]: any } is not index signature · Issue #20011 · microsoft/TypeScript
X Title: { [key in keyof typeof Enum]: any } is not index signature · Issue #20011 · microsoft/TypeScript
Description: TypeScript Version: 2.4.1 Code enum Name { Fred, Vilma } type Names = keyof typeof Name; // type Names = "Fred" | "Vilma"; type Data = ...; const data: { [name in Names]: Data } = { Fred: { ... }, Vilma: { ... }, } function getData(name:...
Open Graph Description: TypeScript Version: 2.4.1 Code enum Name { Fred, Vilma } type Names = keyof typeof Name; // type Names = "Fred" | "Vilma"; type Data = ...; const data: { [name in Names]: Data } = { Fred: { ... }, ...
X Description: TypeScript Version: 2.4.1 Code enum Name { Fred, Vilma } type Names = keyof typeof Name; // type Names = "Fred" | "Vilma"; type Data = ...; const data: { [name in Names]: Data }...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/20011
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"{ [key in keyof typeof Enum]: any } is not index signature","articleBody":"**TypeScript Version:** 2.4.1\r\n\r\n**Code**\r\n```ts\r\nenum Name {\r\n Fred, Vilma\r\n}\r\ntype Names = keyof typeof Name; // type Names = \"Fred\" | \"Vilma\";\r\ntype Data = ...;\r\n\r\nconst data: { [name in Names]: Data } = {\r\n Fred: { ... },\r\n Vilma: { ... },\r\n}\r\n\r\nfunction getData(name: Names) {\r\n return data[strName]; // error here\r\n}\r\n\r\n```\r\n\r\n**Expected behavior:**\r\nNo error\r\n**Actual behavior:**\r\nCompilation error message:\r\n`Element implicitly has an 'any' type because type '{ readonly Fred: Data; readonly Vilma: Data; ...' has no index signature.`\r\n\r\ncan be fixed by casting data to `any` or to `{ [name: string]: Data }` before using indexer\r\n","author":{"url":"https://github.com/CzBuCHi","@type":"Person","name":"CzBuCHi"},"datePublished":"2017-11-14T15:21:01Z","url":"https://github.com/microsoft/TypeScript/issues/20011"}
| 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:68c6163a-f210-c0fd-b57c-1681c6ddecc0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9070:A12D8:2FB9F2:41EA87:6B046B05 |
| html-safe-nonce | 1da6bc081eab058bf68ed3726dcd5f1a4659da95b3eae21dd3633dc63eb4edd2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDcwOkExMkQ4OjJGQjlGMjo0MUVBODc6NkIwNDZCMDUiLCJ2aXNpdG9yX2lkIjoiMTExMzg5NzQ4OTM4NTQxNzQ3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 90c31ee2104c25dfcbb2865a712d1fba50077d29f21bb4206d11777b0a254cd2 |
| hovercard-subject-tag | issue:273830539 |
| 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/20011/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f3e4a1fd411f23f73a62c72dba39a219283d2527e55ca8c901172e350bdbaa36/microsoft/TypeScript/issues/20011 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f3e4a1fd411f23f73a62c72dba39a219283d2527e55ca8c901172e350bdbaa36/microsoft/TypeScript/issues/20011 |
| og:image:alt | TypeScript Version: 2.4.1 Code enum Name { Fred, Vilma } type Names = keyof typeof Name; // type Names = "Fred" | "Vilma"; type Data = ...; const data: { [name in Names]: Data } = { Fred: { ... }, ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | CzBuCHi |
| 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