-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Mixin #56
Comments
Please keep in mind this was a quick proof of concept made for the discussion in microsoft/TypeScript#6502. There are several aspects that are debatable, in particular the signature and implementation of the A first key improvement would be making the base class optional. Please also pay attention to this comment where I hint at some languages improvements that may make this even safer and better. The gist of the comment is that I couldn't find a solution other than introducing a dummy, empty If the TS compiler could see function Mixin<A,B,C>(a: () => A, b: () => B, c: () => C): () => A & B & C { ... }
// Then without an additional interface:
class X extends Mixin(Base, Dog, Duck) { ... } Note that I did not think this through, so maybe it's non-sense ;) |
@jods4 thanks a lot. I'll wait for consensus 🌹 |
This is the placeholder we need to update : https://github.com/basarat/typescript-book/blob/0dbdc38c0df33096797beffc7ce4b9d86ce239e2/docs/tips/mixins.md There is new work on TypeScript master that makes the mixin pattern easier : microsoft/TypeScript#13604 🌹 The new pattern is also covered in a blog post : https://blogs.msdn.microsoft.com/typescript/2017/02/02/announcing-typescript-2-2-rc/ |
Here is a good solution : microsoft/TypeScript#6502 (comment) that uses
Object.assign
microsoft/TypeScript#2919 (comment)
The text was updated successfully, but these errors were encountered: