Created
July 14, 2021 17:12
-
-
Save captain-yossarian/eb0bf0665594944b83a7ae4599cce85d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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