Skip to content

Instantly share code, notes, and snippets.

@antongolub
Last active January 19, 2020 19:06
Show Gist options
  • Save antongolub/1a974a4c49556d3ea9a6697f79e1dda6 to your computer and use it in GitHub Desktop.
Save antongolub/1a974a4c49556d3ea9a6697f79e1dda6 to your computer and use it in GitHub Desktop.
Mixin example from TS docs
// https://www.typescriptlang.org/docs/handbook/mixins.html#mixin-sample
function applyMixins(derivedCtor: any, baseCtors: any[]) {
baseCtors.forEach(baseCtor => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name));
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment