Title: Key Remapping and keyof modifier · Issue #40833 · microsoft/TypeScript · GitHub
Open Graph Title: Key Remapping and keyof modifier · Issue #40833 · microsoft/TypeScript
X Title: Key Remapping and keyof modifier · Issue #40833 · microsoft/TypeScript
Description: TypeScript Version: 4.1.0-beta Using the new key remapping feature, with a remapped object with never keys (for omitting). Passing the remapped object to keyof returns never, instead of the keys from the remapped object. Checks with the ...
Open Graph Description: TypeScript Version: 4.1.0-beta Using the new key remapping feature, with a remapped object with never keys (for omitting). Passing the remapped object to keyof returns never, instead of the keys fr...
X Description: TypeScript Version: 4.1.0-beta Using the new key remapping feature, with a remapped object with never keys (for omitting). Passing the remapped object to keyof returns never, instead of the keys fr...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/40833
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Key Remapping and keyof modifier","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨 -->\r\n\u003c!--\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the CONTRIBUTING guidelines: https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n-->\r\n\r\n\u003c!-- If you have a QUESTION:\r\n THIS IS NOT A FORUM FOR QUESTIONS.\r\n Ask questions at http://stackoverflow.com/questions/tagged/typescript\r\n or https://gitter.im/Microsoft/TypeScript\r\n-->\r\n\r\n\u003c!-- If you have a SUGGESTION:\r\n Most suggestion reports are duplicates, please search extra hard before logging a new suggestion.\r\n See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md\r\n-->\r\n\r\n\u003c!-- If you have a BUG:\r\n Please fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 4.1.0-beta\r\n\r\nUsing the new key remapping feature, with a remapped object with `never` keys (for omitting). Passing the remapped object to `keyof` returns `never`, instead of the keys from the remapped object. Checks with the remapped object _itself_ work as expected - its only when then using `keyof` do they fail.\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** \r\n\r\n- key remapping\r\n- keyof with never\r\n\r\n**Code**\r\n\r\n```ts\r\ntype Example = {foo: string, bar: number}\r\n \r\ntype PickByValueType\u003cT, U> = {\r\n [K in keyof T as T[K] extends U ? K : never]: T[K]\r\n}\r\n\r\ntype T1 = PickByValueType\u003cExample, string>\r\nconst e1: T1 = {\r\n foo: \"hello\"\r\n}\r\ntype T2 = keyof T1\r\nconst e2: T2 = \"foo\"\r\n```\r\n\r\n**Expected behavior:**\r\n\r\n`keyof T1` should be `\"foo\"`\r\n\r\n\r\n**Actual behavior:**\r\n\r\n`keyof T1` is `never`\r\n\r\n`T1` correctly picks out the expected keys based on the condition check, but when ran through `keyof` it seems to lose the \"set\" keys.\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior --> \r\n\r\nhttps://www.typescriptlang.org/play?ts=4.1.0-pr-40336-88&ssl=4&ssc=41&pln=4&pc=46#code/C4TwDgpgBAogHgQwLZgDbQLxQN4DMD2+AXFAM7ABOAlgHYDmANFAEYIUk0CuSzEFAvgCgoUQaEhQAClQDGAawBCIAGoJUnCABVwEADyamAVQB8ULNmFQA2gGkotKHIgh8uKJqgJS72wF0oEHDAEDQAJt6GUAD8UHYcEABufL4kmn6CQmI67gCMZlKyiipqGtqQuvDIaBBM5NT0xoIy+DTkATmpeeaWIgTEUABEABYQqKj4AxlZEpoATPlOLm6aOU0tbRCzqfNYA32TQA\r\n\r\n**Related Issues:**\r\n\r\n- Original PR: https://github.com/microsoft/TypeScript/pull/40336","author":{"url":"https://github.com/shauns","@type":"Person","name":"shauns"},"datePublished":"2020-09-29T17:10:05Z","url":"https://github.com/microsoft/TypeScript/issues/40833"}
| 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:f3e85419-2c99-5db2-edde-c9837966b457 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 903E:26ECEB:31B4EC5:3F35A25:6B01BC7E |
| html-safe-nonce | c852f2d45a8a2770ba6f8c4fa22a904b6d280cd1fe04bb5b45e736a1d5ff1e83 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDNFOjI2RUNFQjozMUI0RUM1OjNGMzVBMjU6NkIwMUJDN0UiLCJ2aXNpdG9yX2lkIjoiNzQxNjk5NDc5NjM3NzU4NjgxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 55ccf7ebe44ad203b38eaa58e30d2d0c9ba399276bf1e2871a043002edca8711 |
| hovercard-subject-tag | issue:711301914 |
| 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/40833/issue_layout |
| twitter:image | https://opengraph.githubassets.com/857bc820f209275115844e513689aba3343f380ac37d83b89cf756c3aaa3452b/microsoft/TypeScript/issues/40833 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/857bc820f209275115844e513689aba3343f380ac37d83b89cf756c3aaa3452b/microsoft/TypeScript/issues/40833 |
| og:image:alt | TypeScript Version: 4.1.0-beta Using the new key remapping feature, with a remapped object with never keys (for omitting). Passing the remapped object to keyof returns never, instead of the keys fr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | shauns |
| 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