Title: keyof of 'mixed' class equals to `string | number` · Issue #31143 · microsoft/TypeScript · GitHub
Open Graph Title: keyof of 'mixed' class equals to `string | number` · Issue #31143 · microsoft/TypeScript
X Title: keyof of 'mixed' class equals to `string | number` · Issue #31143 · microsoft/TypeScript
Description: TypeScript Version: 3.4.3 or 3.5.0-dev.20190427 Search Terms: keyof, anonymous class Code type AnyClass = new (...args: any[]) => any; const mixin =
Open Graph Description: TypeScript Version: 3.4.3 or 3.5.0-dev.20190427 Search Terms: keyof, anonymous class Code type AnyClass = new (...args: any[]) => any; const mixin =
X Description: TypeScript Version: 3.4.3 or 3.5.0-dev.20190427 Search Terms: keyof, anonymous class Code type AnyClass = new (...args: any[]) => any; const mixin = <T extends AnyClass>(Class: T) => cl...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/31143
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"keyof of 'mixed' class equals to `string | number`","articleBody":"\u003c!-- 🚨 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!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** `3.4.3` or `3.5.0-dev.20190427`\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** `keyof`, `anonymous class`\r\n\r\n**Code**\r\n\r\n```ts\r\ntype AnyClass = new (...args: any[]) => any;\r\n\r\nconst mixin = \u003cT extends AnyClass>(Class: T) => class extends Class {a: string};\r\nconst Cl = mixin(class {b = 123});\r\nconst inst = new Cl();\r\n\r\ninst. // \u003c- IntelliSense works fine here and suggests 'a' and 'b' properties\r\n\r\ntype Keys = keyof typeof inst; // Keys = string | number\r\n```\r\n\r\n**Expected behavior:**\r\n`Keys` to be equal to `'a' | 'b'`\r\n\r\n**Actual behavior:**\r\n`Keys` to be equal to `string | number`\r\n\r\n**Playground Link:** [ts-playground](https://www.typescriptlang.org/play/index.html#src=type%20AnyClass%20%3D%20new%20(...args%3A%20any%5B%5D)%20%3D%3E%20any%3B%0D%0A%0D%0Aconst%20mixin%20%3D%20%3CT%20extends%20AnyClass%3E(Class%3A%20T)%20%3D%3E%20class%20extends%20Class%20%7Ba%3A%20string%7D%3B%0D%0Aconst%20Cl%20%3D%20mixin(class%20%7Bb%20%3D%20123%7D)%3B%0D%0Aconst%20inst%20%3D%20new%20Cl()%3B%0D%0A%0D%0Atype%20Keys%20%3D%20keyof%20typeof%20inst%3B)\r\n\r\n**Description:**\r\n_I'm sorry if that is a known bug ot expected behaviour. I did not find a duplicate._\r\nClass `C` is a result of extension of some other class `A` provided as a function argument and class `B` which is declared inside the function body. Such class `C` works fine for the most part, but `keyof InstanceType\u003ctypeof C>` returns `string | number`.\r\n\r\n\r\n\r\nWhile IntelliSense works fine: \r\n\r\n\r\nI'll be glad if you suggest any workarounds for this issue.","author":{"url":"https://github.com/int0h","@type":"Person","name":"int0h"},"datePublished":"2019-04-28T12:13:30Z","url":"https://github.com/microsoft/TypeScript/issues/31143"}
| 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:1c827818-782d-1313-180e-bf14bb7805be |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C14C:CE438:5F272C:8036FC:6B01AFE7 |
| html-safe-nonce | 7550e94e27b93e6e4b51ff88e098401393e6959ed2832c960b04fdffa333e06f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTRDOkNFNDM4OjVGMjcyQzo4MDM2RkM6NkIwMUFGRTciLCJ2aXNpdG9yX2lkIjoiMTk2NjU2MTg2MjI4MDYwMTM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 67f39e9e21e701cd19c2ed8d3536e785a3bc4be7a7fe623c5fa0d88ac92cc1c6 |
| hovercard-subject-tag | issue:438050052 |
| 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/31143/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fa7feea1a7c9acdbf91e1a95aac5bbd9a1283d58ba70f7cd3bbcde642839c73a/microsoft/TypeScript/issues/31143 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fa7feea1a7c9acdbf91e1a95aac5bbd9a1283d58ba70f7cd3bbcde642839c73a/microsoft/TypeScript/issues/31143 |
| og:image:alt | TypeScript Version: 3.4.3 or 3.5.0-dev.20190427 Search Terms: keyof, anonymous class Code type AnyClass = new (...args: any[]) => any; const mixin = |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | int0h |
| 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