1
- import {
2
- ComponentOptions ,
3
- ComponentObjectPropsOptions ,
4
- ExtractPropTypes ,
5
- ExtractDefaultPropTypes ,
6
- ShallowUnwrapRef ,
7
- Ref ,
8
- } from 'vue'
1
+ import { ComponentOptions , ShallowUnwrapRef , Ref } from 'vue'
9
2
10
- import {
11
- ClassComponentHooks ,
12
- EmitsOptions ,
13
- ObjectEmitsOptions ,
14
- Vue ,
15
- VueBase ,
16
- VueConstructor ,
17
- VueMixin ,
18
- } from './vue'
3
+ import { Vue , VueConstructor , VueMixin } from './vue'
19
4
20
5
export function Options < V extends Vue > (
21
6
options : ComponentOptions & ThisType < V >
@@ -67,25 +52,8 @@ export type UnionToIntersection<U> = (
67
52
68
53
export type ExtractInstance < T > = T extends VueMixin < infer V > ? V : never
69
54
70
- export type NarrowEmit < T extends VueBase > = Omit <
71
- T ,
72
- '$emit' | keyof ClassComponentHooks
73
- > &
74
- // Reassign class component hooks as mapped types makes prototype function (`mounted(): void`) instance function (`mounted: () => void`).
75
- ClassComponentHooks & {
76
- // Exclude generic $emit type (`$emit: (event: string, ...args: any[]) => void`) if there are another intersected type.
77
- $emit : T [ '$emit' ] extends ( ( event : string , ...args : any [ ] ) => void ) &
78
- infer R
79
- ? unknown extends R
80
- ? T [ '$emit' ]
81
- : R
82
- : T [ '$emit' ]
83
- }
84
-
85
55
export type MixedVueBase < Mixins extends VueMixin [ ] > = Mixins extends ( infer T ) [ ]
86
- ? VueConstructor <
87
- NarrowEmit < UnionToIntersection < ExtractInstance < T > > & Vue > & VueBase
88
- >
56
+ ? VueConstructor < UnionToIntersection < ExtractInstance < T > > & Vue >
89
57
: never
90
58
91
59
export function mixins < T extends VueMixin [ ] > ( ...Ctors : T ) : MixedVueBase < T >
@@ -108,47 +76,6 @@ export function mixins(...Ctors: VueMixin[]): VueConstructor {
108
76
}
109
77
}
110
78
111
- export function props <
112
- PropNames extends string ,
113
- Props = Readonly < { [ key in PropNames ] ?: any } >
114
- > ( propNames : PropNames [ ] ) : VueConstructor < Vue < Props > & Props >
115
-
116
- export function props <
117
- PropsOptions extends ComponentObjectPropsOptions ,
118
- Props = Readonly < ExtractPropTypes < PropsOptions > > ,
119
- DefaultProps = ExtractDefaultPropTypes < PropsOptions >
120
- > (
121
- propsOptions : PropsOptions
122
- ) : VueConstructor < Vue < Props , { } , DefaultProps > & Props >
123
-
124
- export function props (
125
- propsOptions : string [ ] | ComponentObjectPropsOptions
126
- ) : VueConstructor {
127
- class PropsMixin extends Vue {
128
- static __vccExtend ( options : ComponentOptions ) {
129
- options . props = propsOptions
130
- }
131
- }
132
- return PropsMixin
133
- }
134
-
135
- export function emits < EmitNames extends string > (
136
- emitNames : EmitNames [ ]
137
- ) : VueConstructor < Vue < unknown , EmitNames [ ] > >
138
-
139
- export function emits < EmitsOptions extends ObjectEmitsOptions > (
140
- emitsOptions : EmitsOptions
141
- ) : VueConstructor < Vue < unknown , EmitsOptions > >
142
-
143
- export function emits ( emitsOptions : EmitsOptions ) : VueConstructor {
144
- class EmitsMixin extends Vue {
145
- static __vccExtend ( options : ComponentOptions ) {
146
- options . emits = emitsOptions
147
- }
148
- }
149
- return EmitsMixin
150
- }
151
-
152
79
export type UnwrapSetupValue < T > = T extends Ref < infer R >
153
80
? R
154
81
: ShallowUnwrapRef < T >
0 commit comments