TypeScript Mixins

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • class BeetleGuy implements Climbs, Bulletproof { }
  • applyMixins (BeetleGuy, [Climbs, Bulletproof]);

Parameters

ParameterDescription
derivedCtorThe class that you want to use as the composition class
baseCtorsAn array of classes to be added to the composition class

Remarks

There are three rules to bear in mind with mixins:

  • You use the implements keyword, not the extends keyword when you write your composition class
  • You need to have a matching signature to keep the compiler quiet (but it doesn’t need any real implementation – it will get that from the mixin).
  • You need to call applyMixins with the correct arguments.


Got any TypeScript Question?