vue 2.7.6 → 2.7.9
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/README.md +1 -1
- package/dist/vue.common.dev.js +139 -67
- package/dist/vue.common.prod.js +3 -3
- package/dist/vue.esm.browser.js +137 -66
- package/dist/vue.esm.browser.min.js +3 -3
- package/dist/vue.esm.js +138 -66
- package/dist/vue.js +140 -67
- package/dist/vue.min.js +3 -3
- package/dist/vue.runtime.common.dev.js +112 -58
- package/dist/vue.runtime.common.prod.js +3 -3
- package/dist/vue.runtime.esm.js +111 -57
- package/dist/vue.runtime.js +113 -58
- package/dist/vue.runtime.min.js +3 -3
- package/package.json +2 -2
- package/packages/compiler-sfc/dist/compiler-sfc.js +56 -26
- package/packages/compiler-sfc/package.json +2 -3
- package/packages/compiler-sfc/src/compileTemplate.ts +1 -2
- package/packages/compiler-sfc/src/rewriteDefault.ts +6 -1
- package/packages/compiler-sfc/src/templateCompilerModules/utils.ts +8 -3
- package/packages/compiler-sfc/test/rewriteDefault.spec.ts +245 -0
- package/src/compiler/codegen/index.ts +31 -10
- package/src/core/instance/init.ts +1 -0
- package/src/core/instance/inject.ts +10 -5
- package/src/core/instance/lifecycle.ts +18 -10
- package/src/core/instance/proxy.ts +2 -2
- package/src/core/instance/render.ts +8 -2
- package/src/core/instance/state.ts +1 -1
- package/src/core/observer/index.ts +1 -1
- package/src/core/observer/scheduler.ts +10 -1
- package/src/core/observer/watcher.ts +14 -5
- package/src/core/vdom/modules/directives.ts +9 -1
- package/src/core/vdom/vnode.ts +1 -0
- package/src/types/component.ts +1 -0
- package/src/v3/apiInject.ts +17 -12
- package/src/v3/apiLifecycle.ts +16 -1
- package/src/v3/apiSetup.ts +38 -17
- package/src/v3/apiWatch.ts +2 -5
- package/src/v3/index.ts +1 -1
- package/src/v3/reactivity/effectScope.ts +5 -1
- package/types/index.d.ts +2 -2
- package/types/options.d.ts +24 -9
- package/types/v3-component-options.d.ts +3 -0
- package/types/v3-component-public-instance.d.ts +2 -4
- package/types/v3-define-component.d.ts +34 -34
- package/types/v3-generated.d.ts +11 -2
- package/types/v3-manual-apis.d.ts +2 -2
- package/types/v3-setup-context.d.ts +4 -0
- package/types/vue.d.ts +108 -31
package/src/v3/apiLifecycle.ts
CHANGED
|
@@ -42,7 +42,6 @@ export const onBeforeUpdate = createLifeCycle('beforeUpdate')
|
|
|
42
42
|
export const onUpdated = createLifeCycle('updated')
|
|
43
43
|
export const onBeforeUnmount = createLifeCycle('beforeDestroy')
|
|
44
44
|
export const onUnmounted = createLifeCycle('destroyed')
|
|
45
|
-
export const onErrorCaptured = createLifeCycle('errorCaptured')
|
|
46
45
|
export const onActivated = createLifeCycle('activated')
|
|
47
46
|
export const onDeactivated = createLifeCycle('deactivated')
|
|
48
47
|
export const onServerPrefetch = createLifeCycle('serverPrefetch')
|
|
@@ -51,3 +50,19 @@ export const onRenderTracked =
|
|
|
51
50
|
createLifeCycle<(e: DebuggerEvent) => any>('renderTracked')
|
|
52
51
|
export const onRenderTriggered =
|
|
53
52
|
createLifeCycle<(e: DebuggerEvent) => any>('renderTriggered')
|
|
53
|
+
|
|
54
|
+
export type ErrorCapturedHook<TError = unknown> = (
|
|
55
|
+
err: TError,
|
|
56
|
+
instance: any,
|
|
57
|
+
info: string
|
|
58
|
+
) => boolean | void
|
|
59
|
+
|
|
60
|
+
const injectErrorCapturedHook =
|
|
61
|
+
createLifeCycle<ErrorCapturedHook<any>>('errorCaptured')
|
|
62
|
+
|
|
63
|
+
export function onErrorCaptured<TError = Error>(
|
|
64
|
+
hook: ErrorCapturedHook<TError>,
|
|
65
|
+
target: any = currentInstance
|
|
66
|
+
) {
|
|
67
|
+
injectErrorCapturedHook(hook, target)
|
|
68
|
+
}
|
package/src/v3/apiSetup.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { proxyWithRefUnwrap } from './reactivity/ref'
|
|
|
19
19
|
*/
|
|
20
20
|
export interface SetupContext {
|
|
21
21
|
attrs: Record<string, any>
|
|
22
|
+
listeners: Record<string, Function | Function[]>
|
|
22
23
|
slots: Record<string, () => VNode[]>
|
|
23
24
|
emit: (event: string, ...args: any[]) => any
|
|
24
25
|
expose: (exposed: Record<string, any>) => void
|
|
@@ -87,7 +88,19 @@ function createSetupContext(vm: Component): SetupContext {
|
|
|
87
88
|
let exposeCalled = false
|
|
88
89
|
return {
|
|
89
90
|
get attrs() {
|
|
90
|
-
|
|
91
|
+
if (!vm._attrsProxy) {
|
|
92
|
+
const proxy = (vm._attrsProxy = {})
|
|
93
|
+
def(proxy, '_v_attr_proxy', true)
|
|
94
|
+
syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs')
|
|
95
|
+
}
|
|
96
|
+
return vm._attrsProxy
|
|
97
|
+
},
|
|
98
|
+
get listeners() {
|
|
99
|
+
if (!vm._listenersProxy) {
|
|
100
|
+
const proxy = (vm._listenersProxy = {})
|
|
101
|
+
syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners')
|
|
102
|
+
}
|
|
103
|
+
return vm._listenersProxy
|
|
91
104
|
},
|
|
92
105
|
get slots() {
|
|
93
106
|
return initSlotsProxy(vm)
|
|
@@ -109,26 +122,18 @@ function createSetupContext(vm: Component): SetupContext {
|
|
|
109
122
|
}
|
|
110
123
|
}
|
|
111
124
|
|
|
112
|
-
function
|
|
113
|
-
if (!vm._attrsProxy) {
|
|
114
|
-
const proxy = (vm._attrsProxy = {})
|
|
115
|
-
def(proxy, '_v_attr_proxy', true)
|
|
116
|
-
syncSetupAttrs(proxy, vm.$attrs, emptyObject, vm)
|
|
117
|
-
}
|
|
118
|
-
return vm._attrsProxy
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function syncSetupAttrs(
|
|
125
|
+
export function syncSetupProxy(
|
|
122
126
|
to: any,
|
|
123
127
|
from: any,
|
|
124
128
|
prev: any,
|
|
125
|
-
instance: Component
|
|
129
|
+
instance: Component,
|
|
130
|
+
type: string
|
|
126
131
|
) {
|
|
127
132
|
let changed = false
|
|
128
133
|
for (const key in from) {
|
|
129
134
|
if (!(key in to)) {
|
|
130
135
|
changed = true
|
|
131
|
-
defineProxyAttr(to, key, instance)
|
|
136
|
+
defineProxyAttr(to, key, instance, type)
|
|
132
137
|
} else if (from[key] !== prev[key]) {
|
|
133
138
|
changed = true
|
|
134
139
|
}
|
|
@@ -142,12 +147,17 @@ export function syncSetupAttrs(
|
|
|
142
147
|
return changed
|
|
143
148
|
}
|
|
144
149
|
|
|
145
|
-
function defineProxyAttr(
|
|
150
|
+
function defineProxyAttr(
|
|
151
|
+
proxy: any,
|
|
152
|
+
key: string,
|
|
153
|
+
instance: Component,
|
|
154
|
+
type: string
|
|
155
|
+
) {
|
|
146
156
|
Object.defineProperty(proxy, key, {
|
|
147
157
|
enumerable: true,
|
|
148
158
|
configurable: true,
|
|
149
159
|
get() {
|
|
150
|
-
return instance
|
|
160
|
+
return instance[type][key]
|
|
151
161
|
}
|
|
152
162
|
})
|
|
153
163
|
}
|
|
@@ -171,19 +181,30 @@ export function syncSetupSlots(to: any, from: any) {
|
|
|
171
181
|
}
|
|
172
182
|
|
|
173
183
|
/**
|
|
174
|
-
* @internal use manual type def
|
|
184
|
+
* @internal use manual type def because public setup context type relies on
|
|
185
|
+
* legacy VNode types
|
|
175
186
|
*/
|
|
176
187
|
export function useSlots(): SetupContext['slots'] {
|
|
177
188
|
return getContext().slots
|
|
178
189
|
}
|
|
179
190
|
|
|
180
191
|
/**
|
|
181
|
-
* @internal use manual type def
|
|
192
|
+
* @internal use manual type def because public setup context type relies on
|
|
193
|
+
* legacy VNode types
|
|
182
194
|
*/
|
|
183
195
|
export function useAttrs(): SetupContext['attrs'] {
|
|
184
196
|
return getContext().attrs
|
|
185
197
|
}
|
|
186
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Vue 2 only
|
|
201
|
+
* @internal use manual type def because public setup context type relies on
|
|
202
|
+
* legacy VNode types
|
|
203
|
+
*/
|
|
204
|
+
export function useListeners(): SetupContext['listeners'] {
|
|
205
|
+
return getContext().listeners
|
|
206
|
+
}
|
|
207
|
+
|
|
187
208
|
function getContext(): SetupContext {
|
|
188
209
|
if (__DEV__ && !currentInstance) {
|
|
189
210
|
warn(`useContext() called without active instance.`)
|
package/src/v3/apiWatch.ts
CHANGED
|
@@ -274,10 +274,7 @@ function doWatch(
|
|
|
274
274
|
let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE
|
|
275
275
|
// overwrite default run
|
|
276
276
|
watcher.run = () => {
|
|
277
|
-
if (
|
|
278
|
-
!watcher.active &&
|
|
279
|
-
!(flush === 'pre' && instance && instance._isBeingDestroyed)
|
|
280
|
-
) {
|
|
277
|
+
if (!watcher.active) {
|
|
281
278
|
return
|
|
282
279
|
}
|
|
283
280
|
if (cb) {
|
|
@@ -313,7 +310,7 @@ function doWatch(
|
|
|
313
310
|
if (flush === 'sync') {
|
|
314
311
|
watcher.update = watcher.run
|
|
315
312
|
} else if (flush === 'post') {
|
|
316
|
-
watcher.
|
|
313
|
+
watcher.post = true
|
|
317
314
|
watcher.update = () => queueWatcher(watcher)
|
|
318
315
|
} else {
|
|
319
316
|
// pre
|
package/src/v3/index.ts
CHANGED
|
@@ -77,7 +77,7 @@ export { provide, inject, InjectionKey } from './apiInject'
|
|
|
77
77
|
|
|
78
78
|
export { h } from './h'
|
|
79
79
|
export { getCurrentInstance } from './currentInstance'
|
|
80
|
-
export { useSlots, useAttrs, mergeDefaults } from './apiSetup'
|
|
80
|
+
export { useSlots, useAttrs, useListeners, mergeDefaults } from './apiSetup'
|
|
81
81
|
export { nextTick } from 'core/util/next-tick'
|
|
82
82
|
export { set, del } from 'core/observer'
|
|
83
83
|
|
|
@@ -27,10 +27,14 @@ export class EffectScope {
|
|
|
27
27
|
* @internal
|
|
28
28
|
*/
|
|
29
29
|
scopes: EffectScope[] | undefined
|
|
30
|
+
/**
|
|
31
|
+
* indicates this being a component root scope
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
_vm?: boolean
|
|
30
35
|
/**
|
|
31
36
|
* track a child scope's index in its parent's scopes array for optimized
|
|
32
37
|
* removal
|
|
33
|
-
* @internal
|
|
34
38
|
*/
|
|
35
39
|
private index: number | undefined
|
|
36
40
|
|
package/types/index.d.ts
CHANGED
|
@@ -41,8 +41,8 @@ export * from './v3-setup-helpers'
|
|
|
41
41
|
|
|
42
42
|
export { Data } from './common'
|
|
43
43
|
export { SetupContext } from './v3-setup-context'
|
|
44
|
-
export { defineComponent } from './v3-define-component'
|
|
45
|
-
|
|
44
|
+
export { defineComponent, DefineComponent } from './v3-define-component'
|
|
45
|
+
export { defineAsyncComponent } from './v3-define-async-component'
|
|
46
46
|
export {
|
|
47
47
|
SetupFunction,
|
|
48
48
|
// v2 already has option with same name and it's for a single computed
|
package/types/options.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { VNode, VNodeData, VNodeDirective, NormalizedScopedSlot } from './vnode'
|
|
|
3
3
|
import { SetupContext } from './v3-setup-context'
|
|
4
4
|
import { DebuggerEvent } from './v3-generated'
|
|
5
5
|
import { DefineComponent } from './v3-define-component'
|
|
6
|
+
import { ComponentOptionsMixin } from './v3-component-options'
|
|
6
7
|
|
|
7
8
|
type Constructor = {
|
|
8
9
|
new (...args: any[]): any
|
|
@@ -93,7 +94,9 @@ export type ThisTypedComponentOptionsWithArrayProps<
|
|
|
93
94
|
Methods,
|
|
94
95
|
Computed,
|
|
95
96
|
PropNames extends string,
|
|
96
|
-
SetupBindings
|
|
97
|
+
SetupBindings,
|
|
98
|
+
Mixin,
|
|
99
|
+
Extends
|
|
97
100
|
> = object &
|
|
98
101
|
ComponentOptions<
|
|
99
102
|
V,
|
|
@@ -102,7 +105,9 @@ export type ThisTypedComponentOptionsWithArrayProps<
|
|
|
102
105
|
Computed,
|
|
103
106
|
PropNames[],
|
|
104
107
|
Record<PropNames, any>,
|
|
105
|
-
SetupBindings
|
|
108
|
+
SetupBindings,
|
|
109
|
+
Mixin,
|
|
110
|
+
Extends
|
|
106
111
|
> &
|
|
107
112
|
ThisType<
|
|
108
113
|
CombinedVueInstance<
|
|
@@ -111,7 +116,9 @@ export type ThisTypedComponentOptionsWithArrayProps<
|
|
|
111
116
|
Methods,
|
|
112
117
|
Computed,
|
|
113
118
|
Readonly<Record<PropNames, any>>,
|
|
114
|
-
SetupBindings
|
|
119
|
+
SetupBindings,
|
|
120
|
+
Mixin,
|
|
121
|
+
Extends
|
|
115
122
|
>
|
|
116
123
|
>
|
|
117
124
|
|
|
@@ -124,7 +131,9 @@ export type ThisTypedComponentOptionsWithRecordProps<
|
|
|
124
131
|
Methods,
|
|
125
132
|
Computed,
|
|
126
133
|
Props,
|
|
127
|
-
SetupBindings
|
|
134
|
+
SetupBindings,
|
|
135
|
+
Mixin,
|
|
136
|
+
Extends
|
|
128
137
|
> = object &
|
|
129
138
|
ComponentOptions<
|
|
130
139
|
V,
|
|
@@ -133,7 +142,9 @@ export type ThisTypedComponentOptionsWithRecordProps<
|
|
|
133
142
|
Computed,
|
|
134
143
|
RecordPropsDefinition<Props>,
|
|
135
144
|
Props,
|
|
136
|
-
SetupBindings
|
|
145
|
+
SetupBindings,
|
|
146
|
+
Mixin,
|
|
147
|
+
Extends
|
|
137
148
|
> &
|
|
138
149
|
ThisType<
|
|
139
150
|
CombinedVueInstance<
|
|
@@ -142,7 +153,9 @@ export type ThisTypedComponentOptionsWithRecordProps<
|
|
|
142
153
|
Methods,
|
|
143
154
|
Computed,
|
|
144
155
|
Readonly<Props>,
|
|
145
|
-
SetupBindings
|
|
156
|
+
SetupBindings,
|
|
157
|
+
Mixin,
|
|
158
|
+
Extends
|
|
146
159
|
>
|
|
147
160
|
>
|
|
148
161
|
|
|
@@ -158,7 +171,9 @@ export interface ComponentOptions<
|
|
|
158
171
|
Computed = DefaultComputed,
|
|
159
172
|
PropsDef = PropsDefinition<DefaultProps>,
|
|
160
173
|
Props = DefaultProps,
|
|
161
|
-
RawBindings = {}
|
|
174
|
+
RawBindings = {},
|
|
175
|
+
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
176
|
+
Extends extends ComponentOptionsMixin = ComponentOptionsMixin
|
|
162
177
|
> {
|
|
163
178
|
data?: Data
|
|
164
179
|
props?: PropsDef
|
|
@@ -217,12 +232,12 @@ export interface ComponentOptions<
|
|
|
217
232
|
}
|
|
218
233
|
|
|
219
234
|
parent?: Vue
|
|
220
|
-
mixins?: (ComponentOptions<Vue> | typeof Vue)[]
|
|
235
|
+
mixins?: (Mixin | ComponentOptions<Vue> | typeof Vue)[]
|
|
221
236
|
name?: string
|
|
222
237
|
// for SFC auto name inference w/ ts-loader check
|
|
223
238
|
__name?: string
|
|
224
239
|
// TODO: support properly inferred 'extends'
|
|
225
|
-
extends?: ComponentOptions<Vue> | typeof Vue
|
|
240
|
+
extends?: Extends | ComponentOptions<Vue> | typeof Vue
|
|
226
241
|
delimiters?: [string, string]
|
|
227
242
|
comments?: boolean
|
|
228
243
|
inheritAttrs?: boolean
|
|
@@ -88,6 +88,9 @@ export interface ComponentOptionsBase<
|
|
|
88
88
|
'data' | 'computed' | 'methods' | 'setup' | 'props' | 'mixins' | 'extends'
|
|
89
89
|
>,
|
|
90
90
|
ComponentCustomOptions {
|
|
91
|
+
// allow any options
|
|
92
|
+
[key: string]: any
|
|
93
|
+
|
|
91
94
|
// rewrite options api types
|
|
92
95
|
data?: (
|
|
93
96
|
this: CreateComponentPublicInstance<Props, {}, {}, {}, M, Mixin, Extends>,
|
|
@@ -79,11 +79,11 @@ type ExtractMixin<T> = {
|
|
|
79
79
|
Mixin: MixinToOptionTypes<T>
|
|
80
80
|
}[T extends ComponentOptionsMixin ? 'Mixin' : never]
|
|
81
81
|
|
|
82
|
-
type IntersectionMixin<T> = IsDefaultMixinComponent<T> extends true
|
|
82
|
+
export type IntersectionMixin<T> = IsDefaultMixinComponent<T> extends true
|
|
83
83
|
? OptionTypesType<{}, {}, {}, {}, {}, {}>
|
|
84
84
|
: UnionToIntersection<ExtractMixin<T>>
|
|
85
85
|
|
|
86
|
-
type UnwrapMixinsType<
|
|
86
|
+
export type UnwrapMixinsType<
|
|
87
87
|
T,
|
|
88
88
|
Type extends OptionTypesKeys
|
|
89
89
|
> = T extends OptionTypesType ? T[Type] : never
|
|
@@ -179,9 +179,7 @@ interface Vue3Instance<
|
|
|
179
179
|
? Partial<Defaults> & Omit<P & PublicProps, keyof Defaults>
|
|
180
180
|
: P & PublicProps
|
|
181
181
|
>,
|
|
182
|
-
ComponentPublicInstance | null,
|
|
183
182
|
ComponentPublicInstance,
|
|
184
|
-
ComponentPublicInstance[],
|
|
185
183
|
Options & MergedComponentOptionsOverride,
|
|
186
184
|
EmitFn<E>
|
|
187
185
|
> {}
|
|
@@ -20,7 +20,7 @@ import { Data, HasDefined } from './common'
|
|
|
20
20
|
import { EmitsOptions } from './v3-setup-context'
|
|
21
21
|
import { CreateElement, RenderContext } from './umd'
|
|
22
22
|
|
|
23
|
-
type DefineComponent<
|
|
23
|
+
export type DefineComponent<
|
|
24
24
|
PropsOrPropOptions = {},
|
|
25
25
|
RawBindings = {},
|
|
26
26
|
D = {},
|
|
@@ -67,36 +67,12 @@ type DefineComponent<
|
|
|
67
67
|
props: PropsOrPropOptions
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
/**
|
|
71
|
-
* overload 0.0: functional component with array props
|
|
72
|
-
*/
|
|
73
|
-
export function defineComponent<
|
|
74
|
-
PropNames extends string,
|
|
75
|
-
Props = Readonly<{ [key in PropNames]?: any }>
|
|
76
|
-
>(options: {
|
|
77
|
-
functional: true
|
|
78
|
-
props?: PropNames[]
|
|
79
|
-
render?: (h: CreateElement, context: RenderContext<Props>) => any
|
|
80
|
-
}): DefineComponent<Props>
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* overload 0.1: functional component with object props
|
|
84
|
-
*/
|
|
85
|
-
export function defineComponent<
|
|
86
|
-
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions,
|
|
87
|
-
Props = ExtractPropTypes<PropsOptions>
|
|
88
|
-
>(options: {
|
|
89
|
-
functional: true
|
|
90
|
-
props?: PropsOptions
|
|
91
|
-
render?: (h: CreateElement, context: RenderContext<Props>) => any
|
|
92
|
-
}): DefineComponent<PropsOptions>
|
|
93
|
-
|
|
94
70
|
/**
|
|
95
71
|
* overload 1: object format with no props
|
|
96
72
|
*/
|
|
97
73
|
export function defineComponent<
|
|
98
74
|
RawBindings,
|
|
99
|
-
D =
|
|
75
|
+
D = {},
|
|
100
76
|
C extends ComputedOptions = {},
|
|
101
77
|
M extends MethodOptions = {},
|
|
102
78
|
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
@@ -104,7 +80,7 @@ export function defineComponent<
|
|
|
104
80
|
Emits extends EmitsOptions = {},
|
|
105
81
|
EmitsNames extends string = string
|
|
106
82
|
>(
|
|
107
|
-
options: ComponentOptionsWithoutProps<
|
|
83
|
+
options: { functional?: never } & ComponentOptionsWithoutProps<
|
|
108
84
|
{},
|
|
109
85
|
RawBindings,
|
|
110
86
|
D,
|
|
@@ -125,8 +101,8 @@ export function defineComponent<
|
|
|
125
101
|
*/
|
|
126
102
|
export function defineComponent<
|
|
127
103
|
PropNames extends string,
|
|
128
|
-
RawBindings =
|
|
129
|
-
D =
|
|
104
|
+
RawBindings = {},
|
|
105
|
+
D = {},
|
|
130
106
|
C extends ComputedOptions = {},
|
|
131
107
|
M extends MethodOptions = {},
|
|
132
108
|
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
@@ -135,7 +111,7 @@ export function defineComponent<
|
|
|
135
111
|
EmitsNames extends string = string,
|
|
136
112
|
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
|
|
137
113
|
>(
|
|
138
|
-
options: ComponentOptionsWithArrayProps<
|
|
114
|
+
options: { functional?: never } & ComponentOptionsWithArrayProps<
|
|
139
115
|
PropNames,
|
|
140
116
|
RawBindings,
|
|
141
117
|
D,
|
|
@@ -164,8 +140,8 @@ export function defineComponent<
|
|
|
164
140
|
*/
|
|
165
141
|
export function defineComponent<
|
|
166
142
|
Props,
|
|
167
|
-
RawBindings =
|
|
168
|
-
D =
|
|
143
|
+
RawBindings = {},
|
|
144
|
+
D = {},
|
|
169
145
|
C extends ComputedOptions = {},
|
|
170
146
|
M extends MethodOptions = {},
|
|
171
147
|
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
@@ -175,7 +151,7 @@ export function defineComponent<
|
|
|
175
151
|
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
|
|
176
152
|
>(
|
|
177
153
|
options: HasDefined<Props> extends true
|
|
178
|
-
? ComponentOptionsWithProps<
|
|
154
|
+
? { functional?: never } & ComponentOptionsWithProps<
|
|
179
155
|
PropsOptions,
|
|
180
156
|
RawBindings,
|
|
181
157
|
D,
|
|
@@ -187,7 +163,7 @@ export function defineComponent<
|
|
|
187
163
|
EmitsNames,
|
|
188
164
|
Props
|
|
189
165
|
>
|
|
190
|
-
: ComponentOptionsWithProps<
|
|
166
|
+
: { functional?: never } & ComponentOptionsWithProps<
|
|
191
167
|
PropsOptions,
|
|
192
168
|
RawBindings,
|
|
193
169
|
D,
|
|
@@ -199,3 +175,27 @@ export function defineComponent<
|
|
|
199
175
|
EmitsNames
|
|
200
176
|
>
|
|
201
177
|
): DefineComponent<PropsOptions, RawBindings, D, C, M, Mixin, Extends, Emits>
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* overload 4.1: functional component with array props
|
|
181
|
+
*/
|
|
182
|
+
export function defineComponent<
|
|
183
|
+
PropNames extends string,
|
|
184
|
+
Props = Readonly<{ [key in PropNames]?: any }>
|
|
185
|
+
>(options: {
|
|
186
|
+
functional: true
|
|
187
|
+
props?: PropNames[]
|
|
188
|
+
render?: (h: CreateElement, context: RenderContext<Props>) => any
|
|
189
|
+
}): DefineComponent<Props>
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* overload 4.2: functional component with object props
|
|
193
|
+
*/
|
|
194
|
+
export function defineComponent<
|
|
195
|
+
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions,
|
|
196
|
+
Props = ExtractPropTypes<PropsOptions>
|
|
197
|
+
>(options: {
|
|
198
|
+
functional: true
|
|
199
|
+
props?: PropsOptions
|
|
200
|
+
render?: (h: CreateElement, context: RenderContext<Props>) => any
|
|
201
|
+
}): DefineComponent<PropsOptions>
|
package/types/v3-generated.d.ts
CHANGED
|
@@ -96,7 +96,12 @@ export declare class EffectScope {
|
|
|
96
96
|
/* Excluded from this release type: cleanups */
|
|
97
97
|
/* Excluded from this release type: parent */
|
|
98
98
|
/* Excluded from this release type: scopes */
|
|
99
|
-
/* Excluded from this release type:
|
|
99
|
+
/* Excluded from this release type: _vm */
|
|
100
|
+
/**
|
|
101
|
+
* track a child scope's index in its parent's scopes array for optimized
|
|
102
|
+
* removal
|
|
103
|
+
*/
|
|
104
|
+
private index;
|
|
100
105
|
constructor(detached?: boolean);
|
|
101
106
|
run<T>(fn: () => T): T | undefined;
|
|
102
107
|
/* Excluded from this release type: on */
|
|
@@ -106,6 +111,8 @@ export declare class EffectScope {
|
|
|
106
111
|
|
|
107
112
|
export declare function effectScope(detached?: boolean): EffectScope;
|
|
108
113
|
|
|
114
|
+
export declare type ErrorCapturedHook<TError = unknown> = (err: TError, instance: any, info: string) => boolean | void;
|
|
115
|
+
|
|
109
116
|
/* Excluded from this release type: getCurrentInstance */
|
|
110
117
|
|
|
111
118
|
export declare function getCurrentScope(): EffectScope | undefined;
|
|
@@ -169,7 +176,7 @@ declare type OnCleanup = (cleanupFn: () => void) => void;
|
|
|
169
176
|
|
|
170
177
|
export declare const onDeactivated: (fn: () => void, target?: any) => void;
|
|
171
178
|
|
|
172
|
-
export declare
|
|
179
|
+
export declare function onErrorCaptured<TError = Error>(hook: ErrorCapturedHook<TError>, target?: any): void;
|
|
173
180
|
|
|
174
181
|
export declare const onMounted: (fn: () => void, target?: any) => void;
|
|
175
182
|
|
|
@@ -364,6 +371,8 @@ export declare function useCssModule(name?: string): Record<string, string>;
|
|
|
364
371
|
*/
|
|
365
372
|
export declare function useCssVars(getter: (vm: Record<string, any>, setupProxy: Record<string, any>) => Record<string, string>): void;
|
|
366
373
|
|
|
374
|
+
/* Excluded from this release type: useListeners */
|
|
375
|
+
|
|
367
376
|
/* Excluded from this release type: useSlots */
|
|
368
377
|
|
|
369
378
|
/**
|
|
@@ -5,6 +5,6 @@ export function getCurrentInstance(): { proxy: Vue } | null
|
|
|
5
5
|
|
|
6
6
|
export const h: CreateElement
|
|
7
7
|
|
|
8
|
-
export function useAttrs(): SetupContext['attrs']
|
|
9
|
-
|
|
10
8
|
export function useSlots(): SetupContext['slots']
|
|
9
|
+
export function useAttrs(): SetupContext['attrs']
|
|
10
|
+
export function useListeners(): SetupContext['listeners']
|
|
@@ -31,6 +31,10 @@ export type EmitFn<
|
|
|
31
31
|
|
|
32
32
|
export interface SetupContext<E extends EmitsOptions = {}> {
|
|
33
33
|
attrs: Data
|
|
34
|
+
/**
|
|
35
|
+
* Equivalent of `this.$listeners`, which is Vue 2 only.
|
|
36
|
+
*/
|
|
37
|
+
listeners: Record<string, Function | Function[]>
|
|
34
38
|
slots: Slots
|
|
35
39
|
emit: EmitFn<E>
|
|
36
40
|
expose(exposed?: Record<string, any>): void
|