vue 2.7.0 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vue.common.dev.js +88 -75
- package/dist/vue.common.prod.js +3 -3
- package/dist/vue.esm.browser.js +88 -76
- package/dist/vue.esm.browser.min.js +3 -3
- package/dist/vue.esm.js +89 -76
- package/dist/vue.js +89 -75
- package/dist/vue.min.js +3 -3
- package/dist/vue.runtime.common.dev.js +88 -75
- package/dist/vue.runtime.common.prod.js +3 -3
- package/dist/vue.runtime.esm.js +89 -76
- package/dist/vue.runtime.js +89 -75
- package/dist/vue.runtime.min.js +3 -3
- package/dist/vue.runtime.mjs +89 -76
- package/package.json +2 -2
- package/packages/compiler-sfc/dist/compiler-sfc.js +70 -67
- package/packages/compiler-sfc/package.json +1 -1
- package/packages/compiler-sfc/src/compileScript.ts +12 -15
- package/packages/compiler-sfc/src/parseComponent.ts +6 -1
- package/packages/compiler-sfc/src/templateCompilerModules/srcset.ts +1 -1
- package/packages/compiler-sfc/test/compileScript.spec.ts +12 -0
- package/src/core/observer/index.ts +55 -56
- package/src/core/util/next-tick.ts +2 -1
- package/src/core/vdom/modules/directives.ts +2 -2
- package/src/shared/constants.ts +3 -1
- package/src/shared/util.ts +1 -1
- package/src/v3/apiSetup.ts +4 -21
- package/src/v3/apiWatch.ts +2 -2
- package/src/v3/index.ts +1 -0
- package/src/v3/reactivity/reactive.ts +13 -2
- package/src/v3/reactivity/ref.ts +40 -2
- package/types/common.d.ts +6 -0
- package/types/index.d.ts +7 -4
- package/types/jsx.d.ts +16 -2
- package/types/options.d.ts +7 -1
- package/types/v3-component-options.d.ts +162 -33
- package/types/v3-component-props.d.ts +19 -20
- package/types/v3-component-public-instance.d.ts +230 -0
- package/types/v3-define-component.d.ts +70 -12
- package/types/v3-generated.d.ts +5 -1
- package/types/v3-setup-context.d.ts +0 -6
- package/types/vnode.d.ts +15 -0
- package/types/v3-component-proxy.d.ts +0 -189
|
@@ -2,11 +2,33 @@ import { Vue } from './vue'
|
|
|
2
2
|
import { VNode } from './vnode'
|
|
3
3
|
import { ComponentOptions as Vue2ComponentOptions } from './options'
|
|
4
4
|
import { EmitsOptions, SetupContext } from './v3-setup-context'
|
|
5
|
-
import { Data } from './common'
|
|
6
|
-
import {
|
|
7
|
-
|
|
5
|
+
import { Data, LooseRequired, UnionToIntersection } from './common'
|
|
6
|
+
import {
|
|
7
|
+
ComponentPropsOptions,
|
|
8
|
+
ExtractDefaultPropTypes,
|
|
9
|
+
ExtractPropTypes
|
|
10
|
+
} from './v3-component-props'
|
|
11
|
+
import { CreateComponentPublicInstance } from './v3-component-public-instance'
|
|
8
12
|
export { ComponentPropsOptions } from './v3-component-props'
|
|
9
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Interface for declaring custom options.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* declare module 'vue' {
|
|
20
|
+
* interface ComponentCustomOptions {
|
|
21
|
+
* beforeRouteUpdate?(
|
|
22
|
+
* to: Route,
|
|
23
|
+
* from: Route,
|
|
24
|
+
* next: () => void
|
|
25
|
+
* ): void
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export interface ComponentCustomOptions {}
|
|
31
|
+
|
|
10
32
|
export type ComputedGetter<T> = (ctx?: any) => T
|
|
11
33
|
export type ComputedSetter<T> = (v: T) => void
|
|
12
34
|
|
|
@@ -34,24 +56,76 @@ export type SetupFunction<
|
|
|
34
56
|
ctx: SetupContext<Emits>
|
|
35
57
|
) => RawBindings | (() => VNode | null) | void
|
|
36
58
|
|
|
37
|
-
|
|
59
|
+
type ExtractOptionProp<T> = T extends ComponentOptionsBase<
|
|
60
|
+
infer P, // Props
|
|
61
|
+
any, // RawBindings
|
|
62
|
+
any, // D
|
|
63
|
+
any, // C
|
|
64
|
+
any, // M
|
|
65
|
+
any, // Mixin
|
|
66
|
+
any, // Extends
|
|
67
|
+
any, // EmitsOptions
|
|
68
|
+
any // Defaults
|
|
69
|
+
>
|
|
70
|
+
? unknown extends P
|
|
71
|
+
? {}
|
|
72
|
+
: P
|
|
73
|
+
: {}
|
|
74
|
+
|
|
75
|
+
export interface ComponentOptionsBase<
|
|
38
76
|
Props,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
77
|
+
RawBindings,
|
|
78
|
+
D,
|
|
79
|
+
C extends ComputedOptions,
|
|
80
|
+
M extends MethodOptions,
|
|
81
|
+
Mixin extends ComponentOptionsMixin,
|
|
82
|
+
Extends extends ComponentOptionsMixin,
|
|
83
|
+
Emits extends EmitsOptions,
|
|
84
|
+
EmitNames extends string = string,
|
|
85
|
+
Defaults = {}
|
|
42
86
|
> extends Omit<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
[key: string]: any
|
|
48
|
-
|
|
87
|
+
Vue2ComponentOptions<Vue, D, M, C, Props>,
|
|
88
|
+
'data' | 'computed' | 'methods' | 'setup' | 'props' | 'mixins' | 'extends'
|
|
89
|
+
>,
|
|
90
|
+
ComponentCustomOptions {
|
|
49
91
|
// rewrite options api types
|
|
50
|
-
data?: (
|
|
92
|
+
data?: (
|
|
93
|
+
this: CreateComponentPublicInstance<Props, {}, {}, {}, M, Mixin, Extends>,
|
|
94
|
+
vm: CreateComponentPublicInstance<Props, {}, {}, {}, M, Mixin, Extends>
|
|
95
|
+
) => D
|
|
51
96
|
computed?: C
|
|
52
97
|
methods?: M
|
|
98
|
+
mixins?: Mixin[]
|
|
99
|
+
extends?: Extends
|
|
100
|
+
emits?: (Emits | EmitNames[]) & ThisType<void>
|
|
101
|
+
setup?: SetupFunction<
|
|
102
|
+
Readonly<
|
|
103
|
+
LooseRequired<
|
|
104
|
+
Props &
|
|
105
|
+
UnionToIntersection<ExtractOptionProp<Mixin>> &
|
|
106
|
+
UnionToIntersection<ExtractOptionProp<Extends>>
|
|
107
|
+
>
|
|
108
|
+
>,
|
|
109
|
+
RawBindings,
|
|
110
|
+
Emits
|
|
111
|
+
>
|
|
112
|
+
|
|
113
|
+
__defaults?: Defaults
|
|
53
114
|
}
|
|
54
115
|
|
|
116
|
+
export type ComponentOptionsMixin = ComponentOptionsBase<
|
|
117
|
+
any,
|
|
118
|
+
any,
|
|
119
|
+
any,
|
|
120
|
+
any,
|
|
121
|
+
any,
|
|
122
|
+
any,
|
|
123
|
+
any,
|
|
124
|
+
any,
|
|
125
|
+
any,
|
|
126
|
+
any
|
|
127
|
+
>
|
|
128
|
+
|
|
55
129
|
export type ExtractComputedReturns<T extends any> = {
|
|
56
130
|
[key in keyof T]: T[key] extends { get: (...args: any[]) => infer TReturn }
|
|
57
131
|
? TReturn
|
|
@@ -66,17 +140,36 @@ export type ComponentOptionsWithProps<
|
|
|
66
140
|
D = Data,
|
|
67
141
|
C extends ComputedOptions = {},
|
|
68
142
|
M extends MethodOptions = {},
|
|
69
|
-
Mixin =
|
|
70
|
-
Extends =
|
|
143
|
+
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
144
|
+
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
71
145
|
Emits extends EmitsOptions = {},
|
|
72
146
|
EmitsNames extends string = string,
|
|
73
|
-
Props = ExtractPropTypes<PropsOptions
|
|
74
|
-
|
|
147
|
+
Props = ExtractPropTypes<PropsOptions>,
|
|
148
|
+
Defaults = ExtractDefaultPropTypes<PropsOptions>
|
|
149
|
+
> = ComponentOptionsBase<
|
|
150
|
+
Props,
|
|
151
|
+
RawBindings,
|
|
152
|
+
D,
|
|
153
|
+
C,
|
|
154
|
+
M,
|
|
155
|
+
Mixin,
|
|
156
|
+
Extends,
|
|
157
|
+
Emits,
|
|
158
|
+
EmitsNames,
|
|
159
|
+
Defaults
|
|
160
|
+
> & {
|
|
75
161
|
props?: PropsOptions
|
|
76
|
-
emits?: (Emits | EmitsNames[]) & ThisType<void>
|
|
77
|
-
setup?: SetupFunction<Props, RawBindings, Emits>
|
|
78
162
|
} & ThisType<
|
|
79
|
-
|
|
163
|
+
CreateComponentPublicInstance<
|
|
164
|
+
Props,
|
|
165
|
+
RawBindings,
|
|
166
|
+
D,
|
|
167
|
+
C,
|
|
168
|
+
M,
|
|
169
|
+
Mixin,
|
|
170
|
+
Extends,
|
|
171
|
+
Emits
|
|
172
|
+
>
|
|
80
173
|
>
|
|
81
174
|
|
|
82
175
|
export type ComponentOptionsWithArrayProps<
|
|
@@ -85,17 +178,35 @@ export type ComponentOptionsWithArrayProps<
|
|
|
85
178
|
D = Data,
|
|
86
179
|
C extends ComputedOptions = {},
|
|
87
180
|
M extends MethodOptions = {},
|
|
88
|
-
Mixin =
|
|
89
|
-
Extends =
|
|
181
|
+
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
182
|
+
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
90
183
|
Emits extends EmitsOptions = {},
|
|
91
184
|
EmitsNames extends string = string,
|
|
92
185
|
Props = Readonly<{ [key in PropNames]?: any }>
|
|
93
|
-
> = ComponentOptionsBase<
|
|
186
|
+
> = ComponentOptionsBase<
|
|
187
|
+
Props,
|
|
188
|
+
RawBindings,
|
|
189
|
+
D,
|
|
190
|
+
C,
|
|
191
|
+
M,
|
|
192
|
+
Mixin,
|
|
193
|
+
Extends,
|
|
194
|
+
Emits,
|
|
195
|
+
EmitsNames,
|
|
196
|
+
{}
|
|
197
|
+
> & {
|
|
94
198
|
props?: PropNames[]
|
|
95
|
-
emits?: (Emits | EmitsNames[]) & ThisType<void>
|
|
96
|
-
setup?: SetupFunction<Props, RawBindings, Emits>
|
|
97
199
|
} & ThisType<
|
|
98
|
-
|
|
200
|
+
CreateComponentPublicInstance<
|
|
201
|
+
Props,
|
|
202
|
+
RawBindings,
|
|
203
|
+
D,
|
|
204
|
+
C,
|
|
205
|
+
M,
|
|
206
|
+
Mixin,
|
|
207
|
+
Extends,
|
|
208
|
+
Emits
|
|
209
|
+
>
|
|
99
210
|
>
|
|
100
211
|
|
|
101
212
|
export type ComponentOptionsWithoutProps<
|
|
@@ -104,16 +215,34 @@ export type ComponentOptionsWithoutProps<
|
|
|
104
215
|
D = Data,
|
|
105
216
|
C extends ComputedOptions = {},
|
|
106
217
|
M extends MethodOptions = {},
|
|
107
|
-
Mixin =
|
|
108
|
-
Extends =
|
|
218
|
+
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
219
|
+
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
109
220
|
Emits extends EmitsOptions = {},
|
|
110
221
|
EmitsNames extends string = string
|
|
111
|
-
> = ComponentOptionsBase<
|
|
222
|
+
> = ComponentOptionsBase<
|
|
223
|
+
Props,
|
|
224
|
+
RawBindings,
|
|
225
|
+
D,
|
|
226
|
+
C,
|
|
227
|
+
M,
|
|
228
|
+
Mixin,
|
|
229
|
+
Extends,
|
|
230
|
+
Emits,
|
|
231
|
+
EmitsNames,
|
|
232
|
+
{}
|
|
233
|
+
> & {
|
|
112
234
|
props?: undefined
|
|
113
|
-
emits?: (Emits | EmitsNames[]) & ThisType<void>
|
|
114
|
-
setup?: SetupFunction<Props, RawBindings, Emits>
|
|
115
235
|
} & ThisType<
|
|
116
|
-
|
|
236
|
+
CreateComponentPublicInstance<
|
|
237
|
+
Props,
|
|
238
|
+
RawBindings,
|
|
239
|
+
D,
|
|
240
|
+
C,
|
|
241
|
+
M,
|
|
242
|
+
Mixin,
|
|
243
|
+
Extends,
|
|
244
|
+
Emits
|
|
245
|
+
>
|
|
117
246
|
>
|
|
118
247
|
|
|
119
248
|
export type WithLegacyAPI<T, D, C, M, Props> = T &
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Data } from './common'
|
|
1
|
+
import { Data, IfAny } from './common'
|
|
2
2
|
|
|
3
3
|
export type ComponentPropsOptions<P = Data> =
|
|
4
4
|
| ComponentObjectPropsOptions<P>
|
|
@@ -48,26 +48,25 @@ type ExtractCorrectPropType<T> = T extends Function
|
|
|
48
48
|
? ExtractFunctionPropType<T>
|
|
49
49
|
: Exclude<T, Function>
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
type InferPropType<T> = T extends null
|
|
51
|
+
type InferPropType<T> = [T] extends [null]
|
|
53
52
|
? any // null & true would fail to infer
|
|
54
|
-
: T extends { type: null | true }
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
: [T] extends [{ type: null | true }]
|
|
54
|
+
? any // As TS issue https://github.com/Microsoft/TypeScript/issues/14829 // somehow `ObjectConstructor` when inferred from { (): T } becomes `any` // `BooleanConstructor` when inferred from PropConstructor(with PropMethod) becomes `Boolean`
|
|
55
|
+
: [T] extends [ObjectConstructor | { type: ObjectConstructor }]
|
|
56
|
+
? Record<string, any>
|
|
57
|
+
: [T] extends [BooleanConstructor | { type: BooleanConstructor }]
|
|
58
|
+
? boolean
|
|
59
|
+
: [T] extends [DateConstructor | { type: DateConstructor }]
|
|
60
|
+
? Date
|
|
61
|
+
: [T] extends [(infer U)[] | { type: (infer U)[] }]
|
|
62
|
+
? U extends DateConstructor
|
|
63
|
+
? Date | InferPropType<U>
|
|
64
|
+
: InferPropType<U>
|
|
65
|
+
: [T] extends [Prop<infer V, infer D>]
|
|
66
|
+
? unknown extends V
|
|
67
|
+
? IfAny<V, V, D>
|
|
68
|
+
: V
|
|
69
|
+
: T
|
|
71
70
|
|
|
72
71
|
export type ExtractPropTypes<O> = {
|
|
73
72
|
// use `keyof Pick<O, RequiredKeys<O>>` instead of `RequiredKeys<O>` to support IDE features
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { ExtractDefaultPropTypes, ExtractPropTypes } from './v3-component-props'
|
|
2
|
+
import {
|
|
3
|
+
DebuggerEvent,
|
|
4
|
+
nextTick,
|
|
5
|
+
ShallowUnwrapRef,
|
|
6
|
+
UnwrapNestedRefs,
|
|
7
|
+
WatchOptions,
|
|
8
|
+
WatchStopHandle
|
|
9
|
+
} from './v3-generated'
|
|
10
|
+
import { Data, UnionToIntersection } from './common'
|
|
11
|
+
|
|
12
|
+
import { VueConstructor } from './vue'
|
|
13
|
+
import {
|
|
14
|
+
ComputedOptions,
|
|
15
|
+
MethodOptions,
|
|
16
|
+
ExtractComputedReturns,
|
|
17
|
+
ComponentOptionsMixin,
|
|
18
|
+
ComponentOptionsBase
|
|
19
|
+
} from './v3-component-options'
|
|
20
|
+
import { EmitFn, EmitsOptions, Slots } from './v3-setup-context'
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Custom properties added to component instances in any way and can be accessed through `this`
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { Router } from 'vue-router'
|
|
28
|
+
*
|
|
29
|
+
* declare module 'vue' {
|
|
30
|
+
* interface ComponentCustomProperties {
|
|
31
|
+
* $router: Router
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export interface ComponentCustomProperties {}
|
|
37
|
+
|
|
38
|
+
export type ComponentInstance = InstanceType<VueConstructor>
|
|
39
|
+
|
|
40
|
+
export type OptionTypesKeys = 'P' | 'B' | 'D' | 'C' | 'M' | 'Defaults'
|
|
41
|
+
|
|
42
|
+
export type OptionTypesType<
|
|
43
|
+
P = {},
|
|
44
|
+
B = {},
|
|
45
|
+
D = {},
|
|
46
|
+
C extends ComputedOptions = {},
|
|
47
|
+
M extends MethodOptions = {},
|
|
48
|
+
Defaults = {}
|
|
49
|
+
> = {
|
|
50
|
+
P: P
|
|
51
|
+
B: B
|
|
52
|
+
D: D
|
|
53
|
+
C: C
|
|
54
|
+
M: M
|
|
55
|
+
Defaults: Defaults
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type IsDefaultMixinComponent<T> = T extends ComponentOptionsMixin
|
|
59
|
+
? ComponentOptionsMixin extends T
|
|
60
|
+
? true
|
|
61
|
+
: false
|
|
62
|
+
: false
|
|
63
|
+
|
|
64
|
+
type MixinToOptionTypes<T> = T extends ComponentOptionsBase<
|
|
65
|
+
infer P,
|
|
66
|
+
infer B,
|
|
67
|
+
infer D,
|
|
68
|
+
infer C,
|
|
69
|
+
infer M,
|
|
70
|
+
infer Mixin,
|
|
71
|
+
infer Extends,
|
|
72
|
+
any,
|
|
73
|
+
any,
|
|
74
|
+
infer Defaults
|
|
75
|
+
>
|
|
76
|
+
? OptionTypesType<P & {}, B & {}, D & {}, C & {}, M & {}, Defaults & {}> &
|
|
77
|
+
IntersectionMixin<Mixin> &
|
|
78
|
+
IntersectionMixin<Extends>
|
|
79
|
+
: never
|
|
80
|
+
|
|
81
|
+
// ExtractMixin(map type) is used to resolve circularly references
|
|
82
|
+
type ExtractMixin<T> = {
|
|
83
|
+
Mixin: MixinToOptionTypes<T>
|
|
84
|
+
}[T extends ComponentOptionsMixin ? 'Mixin' : never]
|
|
85
|
+
|
|
86
|
+
type IntersectionMixin<T> = IsDefaultMixinComponent<T> extends true
|
|
87
|
+
? OptionTypesType<{}, {}, {}, {}, {}, {}>
|
|
88
|
+
: UnionToIntersection<ExtractMixin<T>>
|
|
89
|
+
|
|
90
|
+
type UnwrapMixinsType<
|
|
91
|
+
T,
|
|
92
|
+
Type extends OptionTypesKeys
|
|
93
|
+
> = T extends OptionTypesType ? T[Type] : never
|
|
94
|
+
|
|
95
|
+
type EnsureNonVoid<T> = T extends void ? {} : T
|
|
96
|
+
|
|
97
|
+
export type CreateComponentPublicInstance<
|
|
98
|
+
P = {},
|
|
99
|
+
B = {},
|
|
100
|
+
D = {},
|
|
101
|
+
C extends ComputedOptions = {},
|
|
102
|
+
M extends MethodOptions = {},
|
|
103
|
+
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
104
|
+
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
105
|
+
E extends EmitsOptions = {},
|
|
106
|
+
PublicProps = P,
|
|
107
|
+
Defaults = {},
|
|
108
|
+
MakeDefaultsOptional extends boolean = false,
|
|
109
|
+
PublicMixin = IntersectionMixin<Mixin> & IntersectionMixin<Extends>,
|
|
110
|
+
PublicP = UnwrapMixinsType<PublicMixin, 'P'> & EnsureNonVoid<P>,
|
|
111
|
+
PublicB = UnwrapMixinsType<PublicMixin, 'B'> & EnsureNonVoid<B>,
|
|
112
|
+
PublicD = UnwrapMixinsType<PublicMixin, 'D'> & EnsureNonVoid<D>,
|
|
113
|
+
PublicC extends ComputedOptions = UnwrapMixinsType<PublicMixin, 'C'> &
|
|
114
|
+
EnsureNonVoid<C>,
|
|
115
|
+
PublicM extends MethodOptions = UnwrapMixinsType<PublicMixin, 'M'> &
|
|
116
|
+
EnsureNonVoid<M>,
|
|
117
|
+
PublicDefaults = UnwrapMixinsType<PublicMixin, 'Defaults'> &
|
|
118
|
+
EnsureNonVoid<Defaults>
|
|
119
|
+
> = ComponentPublicInstance<
|
|
120
|
+
PublicP,
|
|
121
|
+
PublicB,
|
|
122
|
+
PublicD,
|
|
123
|
+
PublicC,
|
|
124
|
+
PublicM,
|
|
125
|
+
E,
|
|
126
|
+
PublicProps,
|
|
127
|
+
PublicDefaults,
|
|
128
|
+
MakeDefaultsOptional
|
|
129
|
+
>
|
|
130
|
+
|
|
131
|
+
// public properties exposed on the proxy, which is used as the render context
|
|
132
|
+
// in templates (as `this` in the render option)
|
|
133
|
+
export type ComponentPublicInstance<
|
|
134
|
+
P = {}, // props type extracted from props option
|
|
135
|
+
B = {}, // raw bindings returned from setup()
|
|
136
|
+
D = {}, // return from data()
|
|
137
|
+
C extends ComputedOptions = {},
|
|
138
|
+
M extends MethodOptions = {},
|
|
139
|
+
E extends EmitsOptions = {},
|
|
140
|
+
PublicProps = P,
|
|
141
|
+
Defaults = {},
|
|
142
|
+
MakeDefaultsOptional extends boolean = false,
|
|
143
|
+
Options = ComponentOptionsBase<
|
|
144
|
+
any,
|
|
145
|
+
any,
|
|
146
|
+
any,
|
|
147
|
+
any,
|
|
148
|
+
any,
|
|
149
|
+
any,
|
|
150
|
+
any,
|
|
151
|
+
any,
|
|
152
|
+
any,
|
|
153
|
+
any
|
|
154
|
+
>
|
|
155
|
+
> = {
|
|
156
|
+
// $: ComponentInternalInstance
|
|
157
|
+
$data: D
|
|
158
|
+
$props: Readonly<
|
|
159
|
+
MakeDefaultsOptional extends true
|
|
160
|
+
? Partial<Defaults> & Omit<P & PublicProps, keyof Defaults>
|
|
161
|
+
: P & PublicProps
|
|
162
|
+
>
|
|
163
|
+
$attrs: Data
|
|
164
|
+
$refs: Data
|
|
165
|
+
$slots: Slots
|
|
166
|
+
$root: ComponentPublicInstance | null
|
|
167
|
+
$parent: ComponentPublicInstance | null
|
|
168
|
+
$emit: EmitFn<E>
|
|
169
|
+
$el: any
|
|
170
|
+
$options: Options & MergedComponentOptionsOverride
|
|
171
|
+
$forceUpdate: () => void
|
|
172
|
+
$nextTick: typeof nextTick
|
|
173
|
+
$watch(
|
|
174
|
+
source: string | Function,
|
|
175
|
+
cb: Function,
|
|
176
|
+
options?: WatchOptions
|
|
177
|
+
): WatchStopHandle
|
|
178
|
+
} & Readonly<P> &
|
|
179
|
+
ShallowUnwrapRef<B> &
|
|
180
|
+
UnwrapNestedRefs<D> &
|
|
181
|
+
ExtractComputedReturns<C> &
|
|
182
|
+
M &
|
|
183
|
+
ComponentCustomProperties
|
|
184
|
+
|
|
185
|
+
type MergedHook<T = () => void> = T | T[]
|
|
186
|
+
|
|
187
|
+
export type MergedComponentOptionsOverride = {
|
|
188
|
+
beforeCreate?: MergedHook
|
|
189
|
+
created?: MergedHook
|
|
190
|
+
beforeMount?: MergedHook
|
|
191
|
+
mounted?: MergedHook
|
|
192
|
+
beforeUpdate?: MergedHook
|
|
193
|
+
updated?: MergedHook
|
|
194
|
+
activated?: MergedHook
|
|
195
|
+
deactivated?: MergedHook
|
|
196
|
+
/** @deprecated use `beforeUnmount` instead */
|
|
197
|
+
beforeDestroy?: MergedHook
|
|
198
|
+
beforeUnmount?: MergedHook
|
|
199
|
+
/** @deprecated use `unmounted` instead */
|
|
200
|
+
destroyed?: MergedHook
|
|
201
|
+
unmounted?: MergedHook
|
|
202
|
+
renderTracked?: MergedHook<DebuggerHook>
|
|
203
|
+
renderTriggered?: MergedHook<DebuggerHook>
|
|
204
|
+
errorCaptured?: MergedHook<ErrorCapturedHook>
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export type DebuggerHook = (e: DebuggerEvent) => void
|
|
208
|
+
|
|
209
|
+
export type ErrorCapturedHook<TError = unknown> = (
|
|
210
|
+
err: TError,
|
|
211
|
+
instance: ComponentPublicInstance | null,
|
|
212
|
+
info: string
|
|
213
|
+
) => boolean | void
|
|
214
|
+
|
|
215
|
+
export type ComponentPublicInstanceConstructor<
|
|
216
|
+
T extends ComponentPublicInstance<
|
|
217
|
+
Props,
|
|
218
|
+
RawBindings,
|
|
219
|
+
D,
|
|
220
|
+
C,
|
|
221
|
+
M
|
|
222
|
+
> = ComponentPublicInstance<any, any, any>,
|
|
223
|
+
Props = any,
|
|
224
|
+
RawBindings = any,
|
|
225
|
+
D = any,
|
|
226
|
+
C extends ComputedOptions = ComputedOptions,
|
|
227
|
+
M extends MethodOptions = MethodOptions
|
|
228
|
+
> = {
|
|
229
|
+
new (...args: any[]): T
|
|
230
|
+
}
|
|
@@ -1,15 +1,72 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from '..'
|
|
2
|
+
import {
|
|
3
|
+
ComponentPropsOptions,
|
|
4
|
+
ExtractDefaultPropTypes,
|
|
5
|
+
ExtractPropTypes
|
|
6
|
+
} from './v3-component-props'
|
|
2
7
|
import {
|
|
3
8
|
MethodOptions,
|
|
4
9
|
ComputedOptions,
|
|
5
10
|
ComponentOptionsWithoutProps,
|
|
6
11
|
ComponentOptionsWithArrayProps,
|
|
7
|
-
ComponentOptionsWithProps
|
|
12
|
+
ComponentOptionsWithProps,
|
|
13
|
+
ComponentOptionsMixin,
|
|
14
|
+
ComponentOptionsBase
|
|
8
15
|
} from './v3-component-options'
|
|
9
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
ComponentPublicInstanceConstructor,
|
|
18
|
+
CreateComponentPublicInstance
|
|
19
|
+
} from './v3-component-public-instance'
|
|
10
20
|
import { Data, HasDefined } from './common'
|
|
11
21
|
import { EmitsOptions } from './v3-setup-context'
|
|
12
22
|
|
|
23
|
+
type DefineComponent<
|
|
24
|
+
PropsOrPropOptions = {},
|
|
25
|
+
RawBindings = {},
|
|
26
|
+
D = {},
|
|
27
|
+
C extends ComputedOptions = ComputedOptions,
|
|
28
|
+
M extends MethodOptions = MethodOptions,
|
|
29
|
+
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
30
|
+
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
31
|
+
E extends EmitsOptions = {},
|
|
32
|
+
EE extends string = string,
|
|
33
|
+
Props = Readonly<
|
|
34
|
+
PropsOrPropOptions extends ComponentPropsOptions
|
|
35
|
+
? ExtractPropTypes<PropsOrPropOptions>
|
|
36
|
+
: PropsOrPropOptions
|
|
37
|
+
>,
|
|
38
|
+
Defaults = ExtractDefaultPropTypes<PropsOrPropOptions>
|
|
39
|
+
> = ComponentPublicInstanceConstructor<
|
|
40
|
+
CreateComponentPublicInstance<
|
|
41
|
+
Props,
|
|
42
|
+
RawBindings,
|
|
43
|
+
D,
|
|
44
|
+
C,
|
|
45
|
+
M,
|
|
46
|
+
Mixin,
|
|
47
|
+
Extends,
|
|
48
|
+
E,
|
|
49
|
+
Props,
|
|
50
|
+
Defaults,
|
|
51
|
+
true
|
|
52
|
+
> &
|
|
53
|
+
Props
|
|
54
|
+
> &
|
|
55
|
+
ComponentOptionsBase<
|
|
56
|
+
Props,
|
|
57
|
+
RawBindings,
|
|
58
|
+
D,
|
|
59
|
+
C,
|
|
60
|
+
M,
|
|
61
|
+
Mixin,
|
|
62
|
+
Extends,
|
|
63
|
+
E,
|
|
64
|
+
EE,
|
|
65
|
+
Defaults
|
|
66
|
+
> & {
|
|
67
|
+
props: PropsOrPropOptions
|
|
68
|
+
}
|
|
69
|
+
|
|
13
70
|
/**
|
|
14
71
|
* overload 1: object format with no props
|
|
15
72
|
*/
|
|
@@ -18,8 +75,8 @@ export function defineComponent<
|
|
|
18
75
|
D = Data,
|
|
19
76
|
C extends ComputedOptions = {},
|
|
20
77
|
M extends MethodOptions = {},
|
|
21
|
-
Mixin =
|
|
22
|
-
Extends =
|
|
78
|
+
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
79
|
+
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
23
80
|
Emits extends EmitsOptions = {},
|
|
24
81
|
EmitsNames extends string = string
|
|
25
82
|
>(
|
|
@@ -34,7 +91,8 @@ export function defineComponent<
|
|
|
34
91
|
Emits,
|
|
35
92
|
EmitsNames
|
|
36
93
|
>
|
|
37
|
-
):
|
|
94
|
+
): DefineComponent<{}, RawBindings, D, C, M, Mixin, Extends, Emits>
|
|
95
|
+
|
|
38
96
|
/**
|
|
39
97
|
* overload 2: object format with array props declaration
|
|
40
98
|
* props inferred as `{ [key in PropNames]?: any }`
|
|
@@ -47,8 +105,8 @@ export function defineComponent<
|
|
|
47
105
|
D = Data,
|
|
48
106
|
C extends ComputedOptions = {},
|
|
49
107
|
M extends MethodOptions = {},
|
|
50
|
-
Mixin =
|
|
51
|
-
Extends =
|
|
108
|
+
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
109
|
+
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
52
110
|
Emits extends EmitsOptions = {},
|
|
53
111
|
EmitsNames extends string = string,
|
|
54
112
|
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
|
|
@@ -64,7 +122,7 @@ export function defineComponent<
|
|
|
64
122
|
Emits,
|
|
65
123
|
EmitsNames
|
|
66
124
|
>
|
|
67
|
-
):
|
|
125
|
+
): DefineComponent<
|
|
68
126
|
Readonly<{ [key in PropNames]?: any }>,
|
|
69
127
|
RawBindings,
|
|
70
128
|
D,
|
|
@@ -86,8 +144,8 @@ export function defineComponent<
|
|
|
86
144
|
D = Data,
|
|
87
145
|
C extends ComputedOptions = {},
|
|
88
146
|
M extends MethodOptions = {},
|
|
89
|
-
Mixin =
|
|
90
|
-
Extends =
|
|
147
|
+
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
148
|
+
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
91
149
|
Emits extends EmitsOptions = {},
|
|
92
150
|
EmitsNames extends string = string,
|
|
93
151
|
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
|
|
@@ -116,4 +174,4 @@ export function defineComponent<
|
|
|
116
174
|
Emits,
|
|
117
175
|
EmitsNames
|
|
118
176
|
>
|
|
119
|
-
):
|
|
177
|
+
): DefineComponent<PropsOptions, RawBindings, D, C, M, Mixin, Extends, Emits>
|
package/types/v3-generated.d.ts
CHANGED
|
@@ -133,7 +133,9 @@ declare type MultiWatchSources = (WatchSource<unknown> | object)[];
|
|
|
133
133
|
|
|
134
134
|
export declare function nextTick(): Promise<void>;
|
|
135
135
|
|
|
136
|
-
export declare function nextTick(cb: (...args: any[]) => any
|
|
136
|
+
export declare function nextTick<T>(this: T, cb: (this: T, ...args: any[]) => any): void;
|
|
137
|
+
|
|
138
|
+
export declare function nextTick<T>(cb: (this: T, ...args: any[]) => any, ctx: T): void;
|
|
137
139
|
|
|
138
140
|
export declare const onActivated: (fn: () => void, target?: any) => void;
|
|
139
141
|
|
|
@@ -174,6 +176,8 @@ declare type PropOptions = {
|
|
|
174
176
|
|
|
175
177
|
export declare function provide<T>(key: InjectionKey<T> | string | number, value: T): void;
|
|
176
178
|
|
|
179
|
+
export declare function proxyRefs<T extends object>(objectWithRefs: T): ShallowUnwrapRef<T>;
|
|
180
|
+
|
|
177
181
|
declare const RawSymbol: unique symbol;
|
|
178
182
|
|
|
179
183
|
export declare function reactive<T extends object>(target: T): UnwrapNestedRefs<T>;
|
|
@@ -29,12 +29,6 @@ export type EmitFn<
|
|
|
29
29
|
}[Event]
|
|
30
30
|
>
|
|
31
31
|
|
|
32
|
-
export type ComponentRenderEmitFn<
|
|
33
|
-
Options = ObjectEmitsOptions,
|
|
34
|
-
Event extends keyof Options = keyof Options,
|
|
35
|
-
T extends Vue | void = void
|
|
36
|
-
> = EmitFn<Options, Event, T>
|
|
37
|
-
|
|
38
32
|
export interface SetupContext<E extends EmitsOptions = {}> {
|
|
39
33
|
attrs: Data
|
|
40
34
|
slots: Slots
|