Skip to content

Instantly share code, notes, and snippets.

@captain-yossarian
Created July 14, 2021 17:12
Show Gist options
  • Save captain-yossarian/eb0bf0665594944b83a7ae4599cce85d to your computer and use it in GitHub Desktop.
Save captain-yossarian/eb0bf0665594944b83a7ae4599cce85d to your computer and use it in GitHub Desktop.
type ClassType = new (...args: any[]) => any;
function Mixin<T extends ClassType, R extends T[]>(...classRefs: [...R]): InstanceType<R[number]> {
return null as any
}
class Foo {
foo() { }
}
class Bar {
bar() { }
}
class Baz {
baz() {
console.log('baz');
}
}
const result = Mixin(Foo, Bar, Baz) // Foo | Bar | Baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment