Title: Generating type definitions for mixin classes with protected members · Issue #17744 · microsoft/TypeScript · GitHub
Open Graph Title: Generating type definitions for mixin classes with protected members · Issue #17744 · microsoft/TypeScript
X Title: Generating type definitions for mixin classes with protected members · Issue #17744 · microsoft/TypeScript
Description: TypeScript Version: 2.4.2 Code: I'm using mixins as described by: #13743 export type Constructor
Open Graph Description: TypeScript Version: 2.4.2 Code: I'm using mixins as described by: #13743 export type Constructor
X Description: TypeScript Version: 2.4.2 Code: I'm using mixins as described by: #13743 export type Constructor<T> = new(...args: any[]) => T; export function Unsubscriber<T extends Constructor<...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/17744
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generating type definitions for mixin classes with protected members","articleBody":"**TypeScript Version:** 2.4.2\r\n\r\n**Code:**\r\n\r\nI'm using mixins as described by: https://github.com/Microsoft/TypeScript/pull/13743\r\n\r\n```\r\nexport type Constructor\u003cT> = new(...args: any[]) => T;\r\nexport function Unsubscriber\u003cT extends Constructor\u003c{}>>(Base: T) {\r\n class Unsubscriber extends Base implements OnDestroy {\r\n protected unsubscribe: Subject\u003cvoid> = new Subject();\r\n\r\n ngOnDestroy() {\r\n this.unsubscribe.next();\r\n this.unsubscribe.complete();\r\n }\r\n }\r\n return Unsubscriber;\r\n}\r\n```\r\n\r\nIf I compile this code with `\"declaration\": true` to get type definitions for my library, I get the following error:\r\n\r\n```\r\nERROR in (truncated)/mixins.ts (...): Return type of exported function has or is using private name 'Unsubscriber'.\r\n```\r\n\r\nOne solution is to add an interface...\r\n\r\n```\r\nexport interface IUnsubscriber extends OnDestroy {\r\n unsubscribe: Subject\u003cvoid>;\r\n}\r\n```\r\n\r\n...and have my mixin `function` have a return type of `Constructor\u003cIUnsubscriber>`. This works, but it forces me to make the properties/methods exposed by my mixin be `public` even in cases where I want them to be `protected`.\r\n\r\nShort of adding `protected` members to interfaces (which I'm not sure is the right thing to do), this seems to be a limitation of the currently supported mixin strategy.\r\n\r\n","author":{"url":"https://github.com/fr0","@type":"Person","name":"fr0"},"datePublished":"2017-08-11T17:34:57Z","url":"https://github.com/microsoft/TypeScript/issues/17744"}
| 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:5b28a3df-f412-2fa3-4580-79fd156bbd44 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B980:2C69FC:6079C5:80AAD4:6B01A342 |
| html-safe-nonce | d8d8d59b9754e80c09f1804af8c7e0768ac2964c29ec7ac0aec1ac5aa4a44bb6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTgwOjJDNjlGQzo2MDc5QzU6ODBBQUQ0OjZCMDFBMzQyIiwidmlzaXRvcl9pZCI6IjkwNDYyNTU1MDcyODI2OTkwNzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 18becd2bf0cdc66965fd56e798da0ace147e44d364df56e16049f8f774dd0491 |
| hovercard-subject-tag | issue:249700441 |
| 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/17744/issue_layout |
| twitter:image | https://opengraph.githubassets.com/892e4851431e55babd914368b8a1afdc12a4259d3bf3c0e5d0eac11fdfb1f207/microsoft/TypeScript/issues/17744 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/892e4851431e55babd914368b8a1afdc12a4259d3bf3c0e5d0eac11fdfb1f207/microsoft/TypeScript/issues/17744 |
| og:image:alt | TypeScript Version: 2.4.2 Code: I'm using mixins as described by: #13743 export type Constructor |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fr0 |
| 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