Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore Mixins - again #1703

Closed
kum-deepak opened this issue Jul 5, 2020 · 3 comments
Closed

Explore Mixins - again #1703

kum-deepak opened this issue Jul 5, 2020 · 3 comments
Labels
Milestone

Comments

@kum-deepak
Copy link
Collaborator

Investigate if we can do Mixins in a more Typescript friendly way.

Initial lead: https://www.stevefenton.co.uk/2017/08/typescript-mixins-part-two/

@kum-deepak
Copy link
Collaborator Author

The previous way of Mixins worked well for ES6. However, it was not enough for Typescript.

  • We need proper type checking in Mixins themselves - the compiler needs to figure out the methods a Mixin is using from possible Bases.
  • We need proper type checking in derived classes, the compiler needs to figure out all combined methods.

There is some issue around generating declaration for anonymous classes. There are known workarounds based on https://www.typescriptlang.org/docs/handbook/mixins.html. One such workaround is at microsoft/TypeScript#17744 (comment)

After refactoring, we may have fewer Mixins. At that stage, the workaround would be implemented.

@gordonwoodhull
Copy link
Contributor

I took a look at these defineProperty loops. I guess it's a form of metaprogramming, generating the class by running a program.

It's too bad that it does not use language constructs, but I guess it's fairly clear what is going on. In a way it is a step back toward dc@3 in that it builds the classes dynamically instead of using classes and inheritance. 😉

@kum-deepak
Copy link
Collaborator Author

Yes, it feels really sad having to go back.

Our usage is quite specific. So, I guess that we can try some simpler approaches as well. I will get back to it after a few rounds of refactoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants