Title: Using keyof with key remapping to exclude index signatures doesn't return known keys · Issue #41966 · microsoft/TypeScript · GitHub
Open Graph Title: Using keyof with key remapping to exclude index signatures doesn't return known keys · Issue #41966 · microsoft/TypeScript
X Title: Using keyof with key remapping to exclude index signatures doesn't return known keys · Issue #41966 · microsoft/TypeScript
Description: TypeScript Version: 4.2.0-dev.20201211 Search Terms: key remapping remap index signature keyof returns number Code type Compute = { [K in keyof A]: Compute; } & {}; type EqualsTest
Open Graph Description: TypeScript Version: 4.2.0-dev.20201211 Search Terms: key remapping remap index signature keyof returns number Code type Compute = { [K in keyof A]: Compute; } & {}; type EqualsTest X Description: TypeScript Version: 4.2.0-dev.20201211 Search Terms: key remapping remap index signature keyof returns number Code type Compute<A> = { [K in keyof A]: Compute<A[K]>; } & {}; type Eq...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/41966
X: @github
Domain: github.com
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using keyof with key remapping to exclude index signatures doesn't return known keys","articleBody":"\u003c!-- 🚨 STOP 🚨 STOP 🚨 STOP 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\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 FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!--\r\nPlease try to reproduce the issue with the latest published version. It may have already been fixed.\r\nFor npm: `typescript@next`\r\nThis is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly\r\n-->\r\n**TypeScript Version:** 4.2.0-dev.20201211\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\nkey remapping\r\nremap index signature\r\nkeyof returns number\r\n\r\n**Code**\r\n\r\n```ts\r\ntype Compute\u003cA> = { [K in keyof A]: Compute\u003cA[K]>; } & {};\r\n\r\ntype EqualsTest\u003cT> = \u003cA>() => A extends T ? 1 : 0;\r\ntype Equals\u003cA1, A2> = EqualsTest\u003cA2> extends EqualsTest\u003cA1> ? 1 : 0;\r\n\r\ntype Filter\u003cK, I> = Equals\u003cK, I> extends 1 ? never : K;\r\n\r\ntype OmitIndex\u003cT, I extends string | number> = {\r\n [K in keyof T as Filter\u003cK, I>]: T[K];\r\n};\r\n\r\ntype IndexObject = { [key: string]: unknown; };\r\ntype FooBar = { foo: \"hello\"; bar: \"world\"; };\r\n\r\ntype WithIndex = Compute\u003cFooBar & IndexObject>; // { [x: string]: {}; foo: \"hello\"; bar: \"world\"; } \u003c-- OK\r\ntype WithoutIndex = OmitIndex\u003cWithIndex, string>; // { foo: \"hello\"; bar: \"world\"; } \u003c-- OK\r\n\r\ntype FooBarKey = keyof FooBar; // \"foo\" | \"bar\" \u003c-- OK\r\ntype WithIndexKey = keyof WithIndex; // string | number \u003c-- Expected: string \r\ntype WithoutIndexKey = keyof WithoutIndex; // number \u003c-- Expected: \"foo\" | \"bar\"\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nUsing `keyof` with the above remapped type (`WithoutIndex`) should return the known keys (i.e. `\"foo\" | \"bar\"`).\r\n\r\n**Actual behavior:**\r\n\r\nWhile the key remapping in `OmitIndex` appears to successfully omit the string index signature (e.g. `OmitIndex\u003cWithIndex, string> --> { foo: \"hello\"; bar: \"world\"; }`); using `keyof` with the resulting type returns `number`.\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.2.0-dev.20201211#code/C4TwDgpgBAwg9gWzAV2BAPAQQHxQLxQDeUA2gNJQCWAdlANYQhwBmUmAugFyyIppbl22ANxQAvlABkRMcIBQc0JCgBRAI7IAhgBsAzgBUIu4On24CWbAAoAlPlyYoEAB5pqAE11R9UAPxQARihuAAZ5JWh1LT0sAIAaNgAmc1UNHQMjE0xkp1cIDy8o9MNjWNx-IND5RXBoADFKbTQAJ3QyBIBJFKKY9qgu3LdPQL8oaggANwhm4KgyaoioAHkESmAOjxdTTsH84eNmmgBzKAAfMeQEACNplMI5KFIKGnpGFm8oTS8Gpum2zuwXG8gnksgUiw27hcSyuACsIABjYD4IikBggbgHY5A5DUOjUOAAd2oojBizqcDgACFNDMCMRmJTuAAiAAWEG02jgzNEV1pLMJcGa2ncPPEC1qUAA6mtWZCXCj4EhUBgKdTaVJ+ptnDD4UiRI8oAB6I2okjOTHAQ7UI5AwiyKCMuAs9mc7m8-lQZmC4Wi0lQdAAWkDyzINWUMuArLgqHlzhRKzWcfQkbl2oSWJtBpNqKdLo5XLFfOaAqFIrFEkNVer1aDIaWYfD9UpNOaZEYKPR7zVrdENZrOeZTuZZy9xZHjzroab0tlcfbIE7b1YqbjferOczJ3O1EuNxmU5UzkgSIg7kt1pOM9TMfW2oXS6YK9lt7XxtNu+u037hsPx8RaDnl6w6jsy45yEAA\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n\r\nhttps://github.com/microsoft/TypeScript/issues/31143\r\nhttps://github.com/microsoft/TypeScript/issues/41383\r\nhttps://github.com/microsoft/TypeScript/issues/38646\r\n","author":{"url":"https://github.com/tim-stasse","@type":"Person","name":"tim-stasse"},"datePublished":"2020-12-15T14:26:59Z","url":"https://github.com/microsoft/TypeScript/issues/41966"}
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:3635d3ce-0f07-3193-39f6-5d7428034873 current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id BA6C:363D8E:2DAD0D1:39EE03E:6B01A1FB html-safe-nonce c12ab7d61fe1b31162bc9bf68d3ff6009e89ede1670a386786db46b94d74c7ca visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTZDOjM2M0Q4RToyREFEMEQxOjM5RUUwM0U6NkIwMUExRkIiLCJ2aXNpdG9yX2lkIjoiOTA1MzgxNDc0MzE5MDQ5MjExIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= visitor-hmac f9e560999c100e786563944bc80582e8d1a7ba09f9aba0573ef9ba748ed3ddc3 hovercard-subject-tag issue:767649200 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/41966/issue_layout twitter:image https://opengraph.githubassets.com/0e84fc199552fbd467ef9cdf760ec30113d5338072a7134d33e3f9c0c9ad3f87/microsoft/TypeScript/issues/41966 twitter:card summary_large_image og:image https://opengraph.githubassets.com/0e84fc199552fbd467ef9cdf760ec30113d5338072a7134d33e3f9c0c9ad3f87/microsoft/TypeScript/issues/41966 og:image:alt TypeScript Version: 4.2.0-dev.20201211 Search Terms: key remapping remap index signature keyof returns number Code type Compute = { [K in keyof A]: Compute; } & {}; type EqualsTest og:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username tim-stasse 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
URLs of crawlers that visited me.