Title: extends causing string literal can't be used as index · Issue #54886 · microsoft/TypeScript · GitHub
Open Graph Title: extends causing string literal can't be used as index · Issue #54886 · microsoft/TypeScript
X Title: extends causing string literal can't be used as index · Issue #54886 · microsoft/TypeScript
Description: Bug Report 🔎 Search Terms cannot be used as an index type 🕗 Version & Regression Information This changed between versions 4.9.5 and 5.0.4 ⏯ Playground Link Playground link with relevant code 💻 Code interface Dict { foo: 1 bar: 1 } type ...
Open Graph Description: Bug Report 🔎 Search Terms cannot be used as an index type 🕗 Version & Regression Information This changed between versions 4.9.5 and 5.0.4 ⏯ Playground Link Playground link with relevant code 💻 Cod...
X Description: Bug Report 🔎 Search Terms cannot be used as an index type 🕗 Version & Regression Information This changed between versions 4.9.5 and 5.0.4 ⏯ Playground Link Playground link with relevant code 💻...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/54886
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"extends causing string literal can't be used as index","articleBody":"# Bug Report\r\n\r\n\u003c!--\r\n Please fill in each section completely. Thank you!\r\n--\u003e\r\n\r\n### 🔎 Search Terms\r\n\r\ncannot be used as an index type\r\n\r\n### 🕗 Version \u0026 Regression Information\r\n\r\n- This changed between versions 4.9.5 and 5.0.4\r\n\r\n### ⏯ Playground Link\r\n\r\n\u003c!--\r\n A link to a TypeScript Playground \"Share\" link which shows this behavior.\r\n This should have the same code as the code snippet below, and use whichever settings are relevant to your report.\r\n\r\n As a last resort, you can link to a repo, but these will be slower for us to investigate.\r\n--\u003e\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgCLAWZBvAsAKGWRgHsSAuZARgKICM4pKb8BfAgsATwAcUBBZAF40GMAG0A5KRKSAusgD0i5AHcSUANYBnDvm59kAMWHJpZSZ14oAQqfSZxRhcrUadegyiMmR52cgQAB6QIAAm2sgAFP6SyAA+ZgxQkgCUyAD8ZjJxlCAQAG7QSiqgyGAAFhAaXAA0xr5CIkZWhgDC9mJOziXIICRY6lqgAOb1ACrWZgBEMtNxCHAg-Vh0KACu2hBhyHCRS8igYcHl1gB0UQBMAKwAzAAcqUA)\r\n\r\n### 💻 Code\r\n\r\n\u003c!-- Please post the relevant code sample here as well. This code and the Playground code should be the same, do not use separate examples --\u003e\r\n```ts\r\ninterface Dict {\r\n foo: 1\r\n bar: 1\r\n}\r\n\r\ntype A = Dict['foo'] // works\r\n\r\ntype F = 'foo'\r\ntype B = Dict[F] // works\r\n\r\ntype FF = 'foo' extends ('foo' | 'bar') ? 'foo' : never // in theory, FF === F\r\ntype C = Dict[FF] // not working, Type '\"foo\"' cannot be used as an index type.(2538)\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\n\u003c!-- What happened, and why it was wrong --\u003e\r\n`type C` throws error\r\n\r\n### 🙂 Expected behavior\r\n\r\n\u003c!-- What you expected to happen instead, and why --\u003e\r\n\r\nno error","author":{"url":"https://github.com/troy351","@type":"Person","name":"troy351"},"datePublished":"2023-07-05T08:16:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/54886/TypeScript/issues/54886"}
| 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:d1dcefe5-ff32-7790-4973-185302fbb4a1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C362:1AC5B3:4257DE:5AC11F:6A613C4C |
| html-safe-nonce | 262b0f0cc09a19ba5dc051f65bf90b9459a194fab82bdb6f1bde66b02bd01f6b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzYyOjFBQzVCMzo0MjU3REU6NUFDMTFGOjZBNjEzQzRDIiwidmlzaXRvcl9pZCI6IjM1MDg4NzcyNjIwMDcxMjMwMjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cc784a5cc4c93945802259437b457cde9e2b362528d43b176bcc415f11f704ee |
| hovercard-subject-tag | issue:1789029246 |
| 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/54886/issue_layout |
| twitter:image | https://opengraph.githubassets.com/180bfc9d1d71731c3bf5ea7829b74af44ec2090ddadfb2c4d14f14382be389cf/microsoft/TypeScript/issues/54886 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/180bfc9d1d71731c3bf5ea7829b74af44ec2090ddadfb2c4d14f14382be389cf/microsoft/TypeScript/issues/54886 |
| og:image:alt | Bug Report 🔎 Search Terms cannot be used as an index type 🕗 Version & Regression Information This changed between versions 4.9.5 and 5.0.4 ⏯ Playground Link Playground link with relevant code 💻 Cod... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | troy351 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2b7a3d1e6770dc7153450d820fcfe9a7851c4cf2251dcc29c7ad3c5cd1b9e88b |
| 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 | 78cf9d43f120d1f03636ca22ab420bcbb1712804 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width