Discuss anything related to web development but no technical support questions

Post by matthewadams12 »

Hi all, just read https://www.bryntum.com/blog/the-mixin-pattern-in-typescript-all-you-need-to-know-part-2/ by Nickolay Platonov, and I also have been trying to wrap a nice bow around traits in TypeScript for a couple of years now. Unfortunately, I've come up short.

My JavaScript trait library at https://www.npmjs.com/package/@northscaler/mutrait works great, but I can't seem to get the typings correct for my TypeScript port of it.

I have a public git repo available where I'm trying to write the proof-of-concept. If you want to play, just

git clone https://github.com/matthewadams/typescript-trait-test && cd typescript-trait-test && npm install && npm test

I'd appreciate your help! 😊


Post by nickolay »


Glad to talk with a mixin colleague :) Hope you can complete the new iteration on it.

I'm currently happy with my 2nd iteration (2nd blog post), it seems to be quite robust and scales well. Still haven't released it as a separate library but probably will do one day.

The directions to explore as I see:

  • much of the 2nd iteration effort was to work around this issue. That also caused a bit verbose syntax. However, that issue seems to magically resolve itself in TS 3.8.2, so its possible that notation from the 1st iteration can be used again (just need to make sure it works for static members) and copy the "minimal" class instantiation from 2nd iteration.
  • The mixin transformer - would be a holy grail, but requires deep knowledge of TS compiler internals.

Good luck! I'm not planning to join the effort on new iteration right now, however I can help with well-defined questions and just be someone to talk with :) You can reach me at this discord channel: https://discord.gg/jErxFxY (CanonicEpicure)

Post Reply