new (): This
}
+interface ComponentConstructorWithMixins<This> {
+ new <P = {}, D = {}>(): This & { $data: D } & D & { $props: Readonly<P> } & P
+}
+
// mind = blown
// https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type
type UnionToIntersection<U> = (U extends any
: never
export function mixins<
- T extends ComponentConstructor[],
+ T extends ComponentConstructor[] = [],
V = ExtractInstance<T>
->(...args: T): ComponentConstructor<V>
+>(...args: T): ComponentConstructorWithMixins<V>
export function mixins(...args: any[]): any {
// TODO
}
}
}
-class Baz extends mixins(Foo, Bar) {
+class Baz extends mixins(Foo, Bar)<{ baz: number }> {
created() {
this.foo
this.bar
+ this.baz
this.test()
this.ok()
}