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 >
@@ -63,25 +48,8 @@ export type UnionToIntersection<U> = (
63
48
64
49
export type ExtractInstance < T > = T extends VueMixin < infer V > ? V : never
65
50
66
- export type NarrowEmit < T extends VueBase > = Omit <
67
- T ,
68
- '$emit' | keyof ClassComponentHooks
69
- > &
70
- // Reassign class component hooks as mapped types makes prototype function (`mounted(): void`) instance function (`mounted: () => void`).
71
- ClassComponentHooks & {
72
- // Exclude generic $emit type (`$emit: (event: string, ...args: any[]) => void`) if there are another intersected type.
73
- $emit : T [ '$emit' ] extends ( ( event : string , ...args : any [ ] ) => void ) &
74
- infer R
75
- ? unknown extends R
76
- ? T [ '$emit' ]
77
- : R
78
- : T [ '$emit' ]
79
- }
80
-
81
51
export type MixedVueBase < Mixins extends VueMixin [ ] > = Mixins extends ( infer T ) [ ]
82
- ? VueConstructor <
83
- NarrowEmit < UnionToIntersection < ExtractInstance < T > > & Vue > & VueBase
84
- >
52
+ ? VueConstructor < UnionToIntersection < ExtractInstance < T > > & Vue >
85
53
: never
86
54
87
55
export function mixins < T extends VueMixin [ ] > ( ...Ctors : T ) : MixedVueBase < T >
@@ -104,47 +72,6 @@ export function mixins(...Ctors: VueMixin[]): VueConstructor {
104
72
}
105
73
}
106
74
107
- export function props <
108
- PropNames extends string ,
109
- Props = Readonly < { [ key in PropNames ] ?: any } >
110
- > ( propNames : PropNames [ ] ) : VueConstructor < Vue < Props > & Props >
111
-
112
- export function props <
113
- PropsOptions extends ComponentObjectPropsOptions ,
114
- Props = Readonly < ExtractPropTypes < PropsOptions > > ,
115
- DefaultProps = ExtractDefaultPropTypes < PropsOptions >
116
- > (
117
- propsOptions : PropsOptions
118
- ) : VueConstructor < Vue < Props , { } , DefaultProps > & Props >
119
-
120
- export function props (
121
- propsOptions : string [ ] | ComponentObjectPropsOptions
122
- ) : VueConstructor {
123
- class PropsMixin extends Vue {
124
- static __vccExtend ( options : ComponentOptions ) {
125
- options . props = propsOptions
126
- }
127
- }
128
- return PropsMixin
129
- }
130
-
131
- export function emits < EmitNames extends string > (
132
- emitNames : EmitNames [ ]
133
- ) : VueConstructor < Vue < unknown , EmitNames [ ] > >
134
-
135
- export function emits < EmitsOptions extends ObjectEmitsOptions > (
136
- emitsOptions : EmitsOptions
137
- ) : VueConstructor < Vue < unknown , EmitsOptions > >
138
-
139
- export function emits ( emitsOptions : EmitsOptions ) : VueConstructor {
140
- class EmitsMixin extends Vue {
141
- static __vccExtend ( options : ComponentOptions ) {
142
- options . emits = emitsOptions
143
- }
144
- }
145
- return EmitsMixin
146
- }
147
-
148
75
export type UnwrapSetupValue < T > = T extends Ref < infer R >
149
76
? R
150
77
: ShallowUnwrapRef < T >
0 commit comments