Title: Instance member function becomes instance member property in mapped types · Issue #38496 · microsoft/TypeScript · GitHub
Open Graph Title: Instance member function becomes instance member property in mapped types · Issue #38496 · microsoft/TypeScript
X Title: Instance member function becomes instance member property in mapped types · Issue #38496 · microsoft/TypeScript
Description: TypeScript Version: 4.0.0-dev.20200512 Search Terms: instance member function becomes instance member property mixin property of exported class expression may not be private or protected Code export class Application { protected getState...
Open Graph Description: TypeScript Version: 4.0.0-dev.20200512 Search Terms: instance member function becomes instance member property mixin property of exported class expression may not be private or protected Code expor...
X Description: TypeScript Version: 4.0.0-dev.20200512 Search Terms: instance member function becomes instance member property mixin property of exported class expression may not be private or protected Code expor...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/38496
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Instance member function becomes instance member property in mapped types","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!--\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.0.0-dev.20200512`\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- instance member function becomes instance member property\r\n- mixin property of exported class expression may not be private or protected\r\n\r\n**Code**\r\n\r\n```ts\r\nexport class Application {\r\n protected getState() {\r\n return 'starting';\r\n }\r\n\r\n component(componentCtor: typeof Object) {\r\n // mount the component\r\n }\r\n}\r\n\r\n// Ideally, I'd like to write `function repositoryMixin(superClass: typeof Application)`, but that\r\n// triggers \"property of exported class expression may not be private or protected\"\r\nexport function repositoryMixin\u003cT extends MixinTarget\u003cApplication>>(superClass: T) {\r\n return class extends superClass {\r\n component(componentCtor: typeof Object) {\r\n super.component(componentCtor);\r\n // register repositories contributed by the component\r\n }\r\n }\r\n}\r\n\r\n// helpers to work around TypeScript limitations related to mixins\r\n\r\nexport type Constructor\u003cT extends object> = new (...args: any[]) => T;\r\n\r\nexport type MixinTarget\u003cT extends object> = Constructor\u003c\r\n {\r\n // Enumerate only public members to avoid the following compiler error:\r\n // Property '(some-name)' of exported class expression\r\n // may not be private or protected. ts(4094)\r\n [p in keyof T]: T[p];\r\n }\r\n>;\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nThe code compiles cleanly.\r\n\r\n**Actual behavior:**\r\n\r\n```\r\n$ tsc mixin-bug.ts\r\nmixin-bug.ts:13:5 - error TS2425: Class '{ component: (componentCtor: ObjectConstructor) => void; }' defines instance member property 'component', but extended class '(Anonymous class)' defines it as instance member function.\r\n\r\n13 component(componentCtor: typeof Object) {\r\n ~~~~~~~~~\r\n\r\nmixin-bug.ts:14:13 - error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.\r\n\r\n14 super.component(componentCtor);\r\n ~~~~~~~~~\r\n\r\n\r\nFound 2 errors.\r\n```\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=Nightly#code/MYGwhgzhAECCAO8QEthgC7IPYDtoG8AoaaYLAW3lwFMd0AKMymugYXSwCcAuadAT3jUsAM2gB5AEYArasHQBKAsRLQA9GujksAVzp8AFtVIUqOWuhUBfQjcIi987Hk7UqEZB078AssgAeyDgAPAAq0NT+6LQAJjB+gTihYJwA5tTowQhIqBjOAHz59BA6Qpys4FC8oUpEJK7oOpx4oJAwkdE4cdAlZRVtyqomzOZ0jKYs6OxcvAJCohIycoqDQz2l1JwAdExmFuMjFtOcCgDcKkMa0K6pyBDRnNduWB5eyNQwZHScyJI60TFoJJ+IZjLtJhdoDYSDY7FcjCAyjAONAAO5cADW0BSui60FCgmoAGVgD94OhoChyJ48rgYK5wAC+FgtAEghBCIRIlROBS5sZWHT0JwdPIuGEIlFYjAsEt5PloABeaDmVHQehbTUpVIQXhgHD8ADaAF0lIqFaFzlz-Dy+YToAkgsk0hkJR1pdBZbJ5UroIKcPcRWLOMEVHVVFcAKI4HTkTYYYy4EAg+A6SQoYBaajkSSbZEssAANywyEB6CM0BEWBAICwqKCqWG8GQIE2EU4nBmkKuJAACp2ygJoAByeg4MBxhTDz1iblcJmtKCS+CuKDObuaEjkMAgnBYCm56Ar5CFhOex4r-fLagxLboCD0AAsAAYAJyPhSQw3waBBaAY6h+AWUJjWqb9jXOGFCHyc4gADy+YToAkgsk0hkJR1pdBZbJ5UroIKcPcRWLOMEVHVVFcAKI4HTkTYYYy4EAg+A6SQoYBaajkSSbZEssAANywyEB6CM0BEWBAICwqKCqWG8GQIE2EU4nBmkKuJAACp2ygJoAByeg4MBxhTDz1iblcJmtKCS+CuKDObuaEjkMAgnBYCm56Ar5CFhOex4r-fLagxLboCD0AAsAAYAJyPhSQw3waBBaAY6h+AWUJjWqb9jXOGFCHyc4gA\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n\r\n- Remove property-override-method error #34494\r\n- 3.7: instance member function becomes instance member property in type references [outcome: fixed since 3.7.0-dev.20191016] #33747\r\n- Support for all type features in declaration files. #35822\r\n- False error TS4094: ... exported class expression may not be private or protected. #30355\r\n- Allow .d.ts files to represent anonymous class expressions with `private` members #36060\r\n- Unexpected TS4094 with the build parameter `declaration: true`#17293\r\n- Generating type definitions for mixin classes with protected members #17744","author":{"url":"https://github.com/bajtos","@type":"Person","name":"bajtos"},"datePublished":"2020-05-12T08:11:23Z","url":"https://github.com/microsoft/TypeScript/issues/38496"}
| 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:2ab4398b-ca46-6a00-dd92-5819bebb2341 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7A8:31D532:562EED:71FD30:6B019E82 |
| html-safe-nonce | 256098b571e482d6e503fdafb107f8901da547bd618a77b7149d6ddda157333e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0E4OjMxRDUzMjo1NjJFRUQ6NzFGRDMwOjZCMDE5RTgyIiwidmlzaXRvcl9pZCI6IjkwNTQzODYwMzQ5OTI4NDg1MTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ed8f67047d82692dcd35374c85fcdb82bd10749b0db762069348c84f5f01bc5e |
| hovercard-subject-tag | issue:616452895 |
| 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/38496/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1d128cded854011be35d262de2b2b3e5eac7905be7eda60ac8ed9d49e0196278/microsoft/TypeScript/issues/38496 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1d128cded854011be35d262de2b2b3e5eac7905be7eda60ac8ed9d49e0196278/microsoft/TypeScript/issues/38496 |
| og:image:alt | TypeScript Version: 4.0.0-dev.20200512 Search Terms: instance member function becomes instance member property mixin property of exported class expression may not be private or protected Code expor... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bajtos |
| 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