3
3
UnwrapRef ,
4
4
ComponentObjectPropsOptions ,
5
5
ExtractPropTypes ,
6
+ AllowedComponentProps ,
7
+ ComponentCustomProps ,
8
+ VNodeProps ,
6
9
} from 'vue'
7
10
8
11
import {
@@ -64,23 +67,22 @@ export type ExtractInstance<T> = T extends VueMixin<infer V> ? V : never
64
67
export type NarrowEmit < T extends VueBase > = Omit <
65
68
T ,
66
69
'$emit' | keyof ClassComponentHooks
67
- >
70
+ > &
68
71
// Reassign class component hooks as mapped types makes prototype function (`mounted(): void`) instance function (`mounted: () => void`).
69
- & ClassComponentHooks
70
-
71
- // Exclude generic $emit type (`$emit: (event: string, ...args: any[]) => void`) if there are another intersected type.
72
- & {
73
- $emit : T [ '$emit' ] extends ( ( ( event : string , ...args : any [ ] ) => void ) & infer R )
74
- ? unknown extends R
75
- ? T [ '$emit' ]
76
- : R
77
- : T [ '$emit' ]
72
+ ClassComponentHooks & {
73
+ // Exclude generic $emit type (`$emit: (event: string, ...args: any[]) => void`) if there are another intersected type.
74
+ $emit : T [ '$emit' ] extends ( ( event : string , ...args : any [ ] ) => void ) &
75
+ infer R
76
+ ? unknown extends R
77
+ ? T [ '$emit' ]
78
+ : R
79
+ : T [ '$emit' ]
78
80
}
79
81
80
82
export type MixedVueBase < Mixins extends VueMixin [ ] > = Mixins extends ( infer T ) [ ]
81
83
? VueConstructor <
82
- NarrowEmit < UnionToIntersection < ExtractInstance < T > > & Vue > & VueBase
83
- >
84
+ NarrowEmit < UnionToIntersection < ExtractInstance < T > > & Vue > & VueBase
85
+ >
84
86
: never
85
87
86
88
export function mixins < T extends VueMixin [ ] > ( ...Ctors : T ) : MixedVueBase < T >
@@ -96,7 +98,7 @@ export function mixins(...Ctors: VueMixin[]): VueConstructor {
96
98
Ctors . forEach ( ( Ctor ) => {
97
99
const data = new ( Ctor as VueConstructor ) ( ...args )
98
100
Object . keys ( data ) . forEach ( ( key ) => {
99
- ; ( this as any ) [ key ] = ( data as any ) [ key ]
101
+ ; ( this as any ) [ key ] = ( data as any ) [ key ]
100
102
} )
101
103
} )
102
104
}
@@ -106,12 +108,22 @@ export function mixins(...Ctors: VueMixin[]): VueConstructor {
106
108
export function props <
107
109
PropNames extends string ,
108
110
Props = Readonly < { [ key in PropNames ] ?: any } >
109
- > ( propNames : PropNames [ ] ) : VueConstructor < Vue < Props > & Props >
111
+ > (
112
+ propNames : PropNames [ ]
113
+ ) : VueConstructor <
114
+ Vue < Props , { } , VNodeProps & AllowedComponentProps & ComponentCustomProps > &
115
+ Props
116
+ >
110
117
111
118
export function props <
112
119
PropsOptions extends ComponentObjectPropsOptions ,
113
120
Props = Readonly < ExtractPropTypes < PropsOptions > >
114
- > ( propsOptions : PropsOptions ) : VueConstructor < Vue < Props > & Props >
121
+ > (
122
+ propsOptions : PropsOptions
123
+ ) : VueConstructor <
124
+ Vue < Props , { } , VNodeProps & AllowedComponentProps & ComponentCustomProps > &
125
+ Props
126
+ >
115
127
116
128
export function props (
117
129
propsOptions : string [ ] | ComponentObjectPropsOptions
0 commit comments