ts-mixer is a lightweight TypeScript library designed to provide robust mixin functionality, addressing common pitfalls found in other mixin implementations. It enables developers to compose classes through a multiple-inheritance-like mechanism, supporting complex scenarios such as mixing classes that extend other classes, abstract classes (TypeScript >= 4.2), and generic classes (with specific caveats). The current stable version is 6.0.4. The project appears to follow a release cadence driven by feature development and bug fixes, as indicated by its conventional commits usage. Key differentiators include its ability to support static, protected, and private properties, as well as a more resilient approach to constructor complexities and decorator usage compared to simple function-returning-class solutions. It offers different mixing strategies, including ES6 proxies and hard copies, providing flexibility for various use cases.
npm install ts-mixerVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic class mixing with `ts-mixer` to combine functionalities from multiple base classes into a new derived class.
Use `hasMixin(instance, MixinClass)` instead of `instance instanceof MixinClass`.
Refer to the 'Mixing Generic Classes' section in the documentation for the correct `mix` function usage pattern.
Consult the 'Mixing with Decorators' section in the `ts-mixer` documentation for the correct usage pattern.
Review the 'Dealing with Constructors' section in the documentation for workarounds and understanding potential impacts on your constructor logic.
Ensure `Map` is available in your runtime environment, either natively (ES6+) or through a polyfill.
Use the `mix` function provided by `ts-mixer` in conjunction with TypeScript's declaration merging to properly handle generic class mixing.
Replace `instanceof` checks with `ts-mixer`'s `hasMixin(instance, MixinClass)` utility function.
No dependency data recorded yet.