René's URL Explorer Experiment


Title: Mixin language support (with toy implementation) · Issue #2919 · microsoft/TypeScript · GitHub

Open Graph Title: Mixin language support (with toy implementation) · Issue #2919 · microsoft/TypeScript

X Title: Mixin language support (with toy implementation) · Issue #2919 · microsoft/TypeScript

Description: Hello TypeScripters. I might be opening a can of worms which might bring an age of darkness upon us (but see PS). Anyway, I've done an attempt to add language support for mixins. For the user, it is similar to the extends or implements k...

Open Graph Description: Hello TypeScripters. I might be opening a can of worms which might bring an age of darkness upon us (but see PS). Anyway, I've done an attempt to add language support for mixins. For the user, it i...

X Description: Hello TypeScripters. I might be opening a can of worms which might bring an age of darkness upon us (but see PS). Anyway, I've done an attempt to add language support for mixins. For the user, ...

Mail addresses
notifications@github.com

Opengraph URL: https://github.com/microsoft/TypeScript/issues/2919

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Mixin language support (with toy implementation)","articleBody":"Hello TypeScripters.\n\nI might be opening a can of worms which might bring an age of darkness upon us (but see PS). Anyway, I've done an attempt to add language support for mixins.\n\nFor the user, it is similar to the `extends` or `implements` keywords, and thus goes by `mixes`. The semantic intent of the keyword is that a `Mixture` is NOT a derived class of its `Mixins`, it just copies their static and dynamic properties.\n\nSeveral mixins can be supplied, the order determines which property will finally be mixed (newer definitions shadow previous definitions).\n\nWhat this does is roughly equivalent to http://www.typescriptlang.org/Handbook#mixins, except there is no need to copy attributes manually, so mixins become more manageable - hopefully.\n\n``` ts\n\nclass Base {\n    say(hello:string) {\n        console.log(hello);\n    }\n}\n\nclass Mixin1 {\n    something : string = \"Couac couac\";\n\n    fn1() {\n            console.log(this.something);\n    }\n}\n\n\nclass Mixin2 {      \n    something : string = \"shadowing you, little duck!\";  \n\n    fn2() {\n            console.log(\"The dragon is\", this.something);\n    }\n}\n\n/* Only mixes one mixin */\nclass SimpleMixture mixes Mixin1 {\n\n}\n\n/* Mixes several mixins, property definitions in newer mixins (from left\nto right) shadow those from previous mixins AND those in the mixture\nclass itself, including inherited ones. */\nclass MultiMixture extends Base mixes Mixin1, Mixin2 {\n\n}\n\n\nvar sm1 = new SimpleMixture();\nsm1.fn1();\n\nvar sm2 = new MultiMixture();\nsm2.fn1();\nsm2.fn2();\n\nconsole.log( sm1 instanceof Base );\nconsole.log( sm1 instanceof Mixin1 );\nconsole.log( sm2 instanceof Base );\nconsole.log( sm2 instanceof Mixin2 );\n```\n\nWhich emits\n\n``` js\nvar __extends = this.__extends || function (d, b) {\n    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n    function __() { this.constructor = d; }\n    __.prototype = b.prototype;\n    d.prototype = new __();\n};\nvar __applyMixins = this.__applyMixins || function (mixtureTarget) {\n    for(var a=1; a\u003carguments.length; ++a) {\n        var mixin = arguments[a];\n        Object.getOwnPropertyNames(mixin.prototype).forEach( function(name) {\n            mixtureTarget.prototype[name] = mixin.prototype[name];\n        })\n    }; \n};\nvar Base = (function () {\n    function Base() {\n    }\n    Base.prototype.say = function (hello) {\n        console.log(hello);\n    };\n    return Base;\n})();\nvar Mixin1 = (function () {\n    function Mixin1() {\n        this.something = \"Couac couac\";\n    }\n    Mixin1.prototype.fn1 = function () {\n        console.log(this.something);\n    };\n    return Mixin1;\n})();\nvar Mixin2 = (function () {\n    function Mixin2() {\n        this.something = \"shadowing you, little duck!\";\n    }\n    Mixin2.prototype.fn2 = function () {\n        console.log(\"The dragon is\", this.something);\n    };\n    return Mixin2;\n})();\n/* Only mixes one mixin */\nvar SimpleMixture = (function () {\n    function SimpleMixture() {\n        Mixin1.apply(this) ;\n    }\n    __applyMixins(/*mixtureTarget*/ SimpleMixture, Mixin1);\n    return SimpleMixture;\n})();\n/* Mixes several mixins, property definitions in newer mixins (from left\nto right) shadow those from previous mixins AND those in the mixture\nclass itself, including inherited ones. */\nvar MultiMixture = (function (_super) {\n    __extends(MultiMixture, _super);\n    function MultiMixture() {\n        _super.apply(this, arguments);\n        Mixin1.apply(this) ;\n        Mixin2.apply(this) ;\n    }\n    __applyMixins(/*mixtureTarget*/ MultiMixture, Mixin1, Mixin2);\n    return MultiMixture;\n})(Base);\nvar sm1 = new SimpleMixture();\nsm1.fn1();\nvar sm2 = new MultiMixture();\nsm2.fn1();\nsm2.fn2();\nconsole.log(sm1 instanceof Base);\nconsole.log(sm1 instanceof Mixin1);\nconsole.log(sm2 instanceof Base);\nconsole.log(sm2 instanceof Mixin2);\n```\n\nand outputs\n\n``` bash\n>>> Couac couac\n>>> shadowing you, little duck!\n>>> The dragon is shadowing you, little duck!\n>>> false\n>>> false\n>>> true\n>>> false\n```\n\nAt this point it seems to work with target ES\u003c6 with quite some limitations (the user can't pass arguments to the mixin constructors). Type checking seems to be working (although I could not make Eclipse or Emacs behave with the new keyword). But be warned Very early experimental preview code from a bad JS programmer who knew nothing about TSC's internals three days ago and who was in a rush. Be warned.\n\nI did this to overcome a maintainability issue with my code and rushed this implementation. It was also an exercise to learn more about TSC. I'm also aware that it might not be a great idea to add keywords to a language each time one gets into trouble, but if others see interest in it or you have suggestions, the branch is here https://github.com/dbarbeau/TypeScript/tree/mixes. Just don't expect this implementation to be stable/complete/anything. Actually, if it can just spark some interest/discussion on how to make mixins more useable, then I'm ok with that.\n\nDaniel\nPS: Don't get mad at me :)\nPS: I'm now testing this with more \"serious code\", I will quickly see if it is indeed practical.\n","author":{"url":"https://github.com/dbarbeau","@type":"Person","name":"dbarbeau"},"datePublished":"2015-04-25T21:12:25Z","url":"https://github.com/microsoft/TypeScript/issues/2919"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0be9c211-316a-8174-aa9a-fa5e766ac4af
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDA3A:3F8AB1:740E32:977E84:6B00D458
html-safe-nonce44b12f2bfb9f226b045a7f427c9a6f26c183a4a5cdf1ccddb10ee00723069162
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTNBOjNGOEFCMTo3NDBFMzI6OTc3RTg0OjZCMDBENDU4IiwidmlzaXRvcl9pZCI6IjQxNTkxMjQwNTM1MjI2OTkzNTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac6cab6dc4b2f0b236f8fa305a4b7355bb116cbfadceb1cc17aee71be7afa0ed5c
hovercard-subject-tagissue:70967351
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/2919/issue_layout
twitter:imagehttps://opengraph.githubassets.com/41f0dd0682ea938f4003c00336648103b0a10469585d7ecd4a13de5d7a6c3536/microsoft/TypeScript/issues/2919
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/41f0dd0682ea938f4003c00336648103b0a10469585d7ecd4a13de5d7a6c3536/microsoft/TypeScript/issues/2919
og:image:altHello TypeScripters. I might be opening a can of worms which might bring an age of darkness upon us (but see PS). Anyway, I've done an attempt to add language support for mixins. For the user, it i...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedbarbeau
hostnamegithub.com
expected-hostnamegithub.com
None85bbdfe2b6ba16e234513bc6ceff5d848ef8449820c900692a2b4e67061931e5
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4943239a6d2c591325dad6e5c313e1cafda877f6
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/2919#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F2919
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F2919
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/2919
Reloadhttps://github.com/microsoft/TypeScript/issues/2919
Reloadhttps://github.com/microsoft/TypeScript/issues/2919
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests307 (307)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/2919
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/2919
Mixin language support (with toy implementation)https://github.com/microsoft/TypeScript/issues/2919#top
DiscussionIssues which may not have code impacthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Discussion%22
https://github.com/dbarbeau
Daniel (dbarbeau)https://github.com/dbarbeau
on Apr 25, 2015https://github.com/microsoft/TypeScript/issues/2919#issue-70967351
http://www.typescriptlang.org/Handbook#mixinshttp://www.typescriptlang.org/Handbook#mixins
https://github.com/dbarbeau/TypeScript/tree/mixeshttps://github.com/dbarbeau/TypeScript/tree/mixes
Nexthttps://github.com/microsoft/TypeScript/issues/2919?timeline_page=1
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
DiscussionIssues which may not have code impacthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Discussion%22
on Apr 27, 2015https://github.com/microsoft/TypeScript/issues/2919#event-290423379
https://github.com/DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on Apr 27, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-96470113
Daniel (@dbarbeau)https://github.com/dbarbeau
https://github.com/whitneyit
James Whitney (whitneyit)https://github.com/whitneyit
on Apr 27, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-96484516
#311https://github.com/microsoft/TypeScript/issues/311
https://github.com/dbarbeau
Daniel (dbarbeau)https://github.com/dbarbeau
on Apr 27, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-96580458
https://github.com/whitneyit
James Whitney (whitneyit)https://github.com/whitneyit
on Apr 27, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-96581137
#2919 (comment)https://github.com/microsoft/TypeScript/issues/2919#issuecomment-96580458
https://github.com/dbarbeau
Daniel (dbarbeau)https://github.com/dbarbeau
on Apr 27, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-96589093
https://github.com/danquirk
Dan Quirk (danquirk)https://github.com/danquirk
on Apr 27, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-96762831
#371https://github.com/microsoft/TypeScript/issues/371
#727https://github.com/microsoft/TypeScript/issues/727
#1256https://github.com/microsoft/TypeScript/issues/1256
https://github.com/dbarbeau
Daniel (dbarbeau)https://github.com/dbarbeau
on Apr 27, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-96812779
Dan Quirk (@danquirk)https://github.com/danquirk
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/dbarbeau
Daniel (dbarbeau)https://github.com/dbarbeau
on Apr 27, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-96814089
https://github.com/jbondc
Jon (jbondc)https://github.com/jbondc
on Apr 28, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-97087015
Daniel (@dbarbeau)https://github.com/dbarbeau
https://wiki.php.net/rfc/traitshttps://wiki.php.net/rfc/traits
https://github.com/dbarbeau
Daniel (dbarbeau)https://github.com/dbarbeau
on Apr 29, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-97377392
Jon (@jbondc)https://github.com/jbondc
https://github.com/dead-claudia
Claudia Meadows (dead-claudia)https://github.com/dead-claudia
on Jun 17, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-112679124
#3536https://github.com/microsoft/TypeScript/issues/3536
https://github.com/nippur72
nino-porcino (nippur72)https://github.com/nippur72
on Jun 29, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-116739579
https://github.com/dead-claudia
Claudia Meadows (dead-claudia)https://github.com/dead-claudia
on Jun 29, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-116871972
https://github.com/benliddicott
benliddicotthttps://github.com/benliddicott
on Jul 14, 2015https://github.com/microsoft/TypeScript/issues/2919#issuecomment-121320628
#3854https://github.com/microsoft/TypeScript/issues/3854
https://github.com/jklmli
Kevin Li (jklmli)https://github.com/jklmli
on Feb 23, 2016https://github.com/microsoft/TypeScript/issues/2919#issuecomment-187449400
jods (@jods4)https://github.com/jods4
https://github.com/unional
Homa Wong (unional)https://github.com/unional
on Mar 9, 2016https://github.com/microsoft/TypeScript/issues/2919#issuecomment-194472423
https://github.com/jklmli
Kevin Li (jklmli)https://github.com/jklmli
on Mar 11, 2016https://github.com/microsoft/TypeScript/issues/2919#issuecomment-195553689
Homa Wong (@unional)https://github.com/unional
https://github.com/jklmli
Kevin Li (jklmli)https://github.com/jklmli
on Mar 11, 2016https://github.com/microsoft/TypeScript/issues/2919#issuecomment-195555699
Daniel Rosenwasser (@DanielRosenwasser)https://github.com/DanielRosenwasser
https://github.com/jods4
jods (jods4)https://github.com/jods4
on Mar 12, 2016https://github.com/microsoft/TypeScript/issues/2919#issuecomment-195619812
https://github.com/jklmli
Kevin Li (jklmli)https://github.com/jklmli
on Mar 12, 2016https://github.com/microsoft/TypeScript/issues/2919#issuecomment-195624900
jods (@jods4)https://github.com/jods4
https://github.com/dead-claudia
Claudia Meadows (dead-claudia)https://github.com/dead-claudia
on Mar 12, 2016https://github.com/microsoft/TypeScript/issues/2919#issuecomment-195661592
https://github.com/falsandtru
falsandtru (falsandtru)https://github.com/falsandtru
on Jun 11, 2016https://github.com/microsoft/TypeScript/issues/2919#issuecomment-225398629
https://github.com/kitsonk
Kitson Kelly (kitsonk)https://github.com/kitsonk
on Jun 12, 2016https://github.com/microsoft/TypeScript/issues/2919#issuecomment-225413513
falsandtru (@falsandtru)https://github.com/falsandtru
dojo-composehttps://github.com/dojo/compose
https://github.com/dead-claudia
Claudia Meadows (dead-claudia)https://github.com/dead-claudia
on Jun 17, 2016https://github.com/microsoft/TypeScript/issues/2919#issuecomment-226814642
https://github.com/shlomiassaf
Shlomi Assaf (shlomiassaf)https://github.com/shlomiassaf
on Nov 30, 2016https://github.com/microsoft/TypeScript/issues/2919#issuecomment-263761909
Kitson Kelly (@kitsonk)https://github.com/kitsonk
falsandtru (@falsandtru)https://github.com/falsandtru
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Jan 30, 2017https://github.com/microsoft/TypeScript/issues/2919#issuecomment-276218409
#13743https://github.com/microsoft/TypeScript/pull/13743
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jan 30, 2017https://github.com/microsoft/TypeScript/issues/2919#event-942221556
https://github.com/hoegge
Morten H Pedersen (hoegge)https://github.com/hoegge
on Jul 13, 2017https://github.com/microsoft/TypeScript/issues/2919#issuecomment-315014666
https://www.typescriptlang.org/docs/handbook/mixins.htmlhttps://www.typescriptlang.org/docs/handbook/mixins.html
microsofthttps://github.com/microsoft
on Jun 18, 2018https://github.com/microsoft/TypeScript/issues/2919#event-1686931657
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/2919
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/2919
DiscussionIssues which may not have code impacthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Discussion%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.