TypeScript Mixins

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9

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?