Title: Feature request: Support for using mixins inside other mixins. · Issue #32004 · microsoft/TypeScript · GitHub
Open Graph Title: Feature request: Support for using mixins inside other mixins. · Issue #32004 · microsoft/TypeScript
X Title: Feature request: Support for using mixins inside other mixins. · Issue #32004 · microsoft/TypeScript
Description: Search Terms Suggestion Based on https://stackoverflow.com/questions/56680049, it seems mixin classes can't be used inside other mixins. It'd be great if, in that example, the outer mixin would be able to successfully use the props and t...
Open Graph Description: Search Terms Suggestion Based on https://stackoverflow.com/questions/56680049, it seems mixin classes can't be used inside other mixins. It'd be great if, in that example, the outer mixin would be ...
X Description: Search Terms Suggestion Based on https://stackoverflow.com/questions/56680049, it seems mixin classes can't be used inside other mixins. It'd be great if, in that example, the outer mixin w...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/32004
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature request: Support for using mixins inside other mixins.","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. Please read the FAQ first, especially the \"Common Feature Requests\" section.\r\n\r\n-->\r\n\r\n## Search Terms\r\n\r\n\r\n## Suggestion\r\n\r\nBased on https://stackoverflow.com/questions/56680049, it seems mixin classes can't be used inside other mixins.\r\n\r\nIt'd be great if, in that example, the outer mixin would be able to successfully use the props and types from the Sizeable mixin.\r\n\r\nNote, in the example, `Sizeable` is a class with a default Base class applied, and `.mixin` is the mixin function used to create it.\r\n\r\nBasically, the following (in JS, and simplified):\r\n\r\n```js\r\nfunction SizeableMixin(Base = class {}) {\r\n return class Sizeable extends Base {...}\r\n}\r\n\r\nconst Sizeable = SizeableMixin()\r\nSizeable.mixin = SizeableMixin\r\n\r\nexport default Sizeable\r\n```\r\n\r\nSo it's just a regular class-factory mixin (with a default application so that it is easy to extend like a normal class when used as a base class).\r\n\r\n## Use Cases\r\n\r\nTo be able to use Mixins anywhere, including inside other mixins.\r\n\r\n## Examples\r\n\r\n```js\r\nimport Sizeable from './Sizeable'\r\n\r\nfunction FooMixin\u003cT extends Constructor>(Base: T) {\r\n const Parent = Sizeable.mixin(Base)\r\n return class Foo extends Parent { ... } // ERROR, [Parent] is not a constructor function.\r\n}\r\n\r\nconst Foo = FooMixin()\r\nFoo.mixin = FooMixin // ignore types here, for now\r\n\r\nexport default Foo\r\n```\r\n\r\nBut actually, `Parent` **_is_** a constructor. We know it is. It'd be great to use it.\r\n\r\nIn the Foo mixin, I should at least be able to correctly use Sizeable properties and methods, as if Sizeable were the base class.\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n\r\n* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)\r\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n\r\n","author":{"url":"https://github.com/trusktr","@type":"Person","name":"trusktr"},"datePublished":"2019-06-20T17:41:18Z","url":"https://github.com/microsoft/TypeScript/issues/32004"}
| 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:6ad5f8e8-87d3-76f1-6d7a-6ffd89f24f92 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E260:3A8E64:9D2580:D075C7:6B01B952 |
| html-safe-nonce | 0b4990af4f9d059ac0a6858f79bcaa9044dd571b82ed37747898caef3740d8bb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjYwOjNBOEU2NDo5RDI1ODA6RDA3NUM3OjZCMDFCOTUyIiwidmlzaXRvcl9pZCI6IjQ5MDUyNjE0MTAxNTk4MDI3MDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | da72e464c7452b23dde6e4eee75ae4b97cc0c5d076be64e3da57fdd179a4e01b |
| hovercard-subject-tag | issue:458785935 |
| 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/32004/issue_layout |
| twitter:image | https://opengraph.githubassets.com/284eaad0b99efd6d3b9d9eddca58e9fbf70f33ce4eb5398cb4e81f36e5325387/microsoft/TypeScript/issues/32004 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/284eaad0b99efd6d3b9d9eddca58e9fbf70f33ce4eb5398cb4e81f36e5325387/microsoft/TypeScript/issues/32004 |
| og:image:alt | Search Terms Suggestion Based on https://stackoverflow.com/questions/56680049, it seems mixin classes can't be used inside other mixins. It'd be great if, in that example, the outer mixin would be ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trusktr |
| 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