|
@@ -48,7 +48,10 @@ import {
|
|
|
} from './componentProps'
|
|
} from './componentProps'
|
|
|
import { EmitsOptions } from './componentEmits'
|
|
import { EmitsOptions } from './componentEmits'
|
|
|
import { Directive } from './directives'
|
|
import { Directive } from './directives'
|
|
|
-import { ComponentPublicInstance } from './componentProxy'
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ CreateComponentPublicInstance,
|
|
|
|
|
+ ComponentPublicInstance
|
|
|
|
|
+} from './componentProxy'
|
|
|
import { warn } from './warning'
|
|
import { warn } from './warning'
|
|
|
import { VNodeChild } from './vnode'
|
|
import { VNodeChild } from './vnode'
|
|
|
|
|
|
|
@@ -78,10 +81,12 @@ export interface ComponentOptionsBase<
|
|
|
D,
|
|
D,
|
|
|
C extends ComputedOptions,
|
|
C extends ComputedOptions,
|
|
|
M extends MethodOptions,
|
|
M extends MethodOptions,
|
|
|
|
|
+ Mixin extends ComponentOptionsMixin,
|
|
|
|
|
+ Extends extends ComponentOptionsMixin,
|
|
|
E extends EmitsOptions,
|
|
E extends EmitsOptions,
|
|
|
EE extends string = string
|
|
EE extends string = string
|
|
|
>
|
|
>
|
|
|
- extends LegacyOptions<Props, D, C, M>,
|
|
|
|
|
|
|
+ extends LegacyOptions<Props, D, C, M, Mixin, Extends>,
|
|
|
SFCInternalOptions,
|
|
SFCInternalOptions,
|
|
|
ComponentCustomOptions {
|
|
ComponentCustomOptions {
|
|
|
setup?: (
|
|
setup?: (
|
|
@@ -148,12 +153,24 @@ export type ComponentOptionsWithoutProps<
|
|
|
D = {},
|
|
D = {},
|
|
|
C extends ComputedOptions = {},
|
|
C extends ComputedOptions = {},
|
|
|
M extends MethodOptions = {},
|
|
M extends MethodOptions = {},
|
|
|
|
|
+ Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
|
|
|
+ Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
|
E extends EmitsOptions = EmitsOptions,
|
|
E extends EmitsOptions = EmitsOptions,
|
|
|
EE extends string = string
|
|
EE extends string = string
|
|
|
-> = ComponentOptionsBase<Props, RawBindings, D, C, M, E, EE> & {
|
|
|
|
|
|
|
+> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE> & {
|
|
|
props?: undefined
|
|
props?: undefined
|
|
|
} & ThisType<
|
|
} & ThisType<
|
|
|
- ComponentPublicInstance<{}, RawBindings, D, C, M, E, Readonly<Props>>
|
|
|
|
|
|
|
+ CreateComponentPublicInstance<
|
|
|
|
|
+ {},
|
|
|
|
|
+ RawBindings,
|
|
|
|
|
+ D,
|
|
|
|
|
+ C,
|
|
|
|
|
+ M,
|
|
|
|
|
+ Mixin,
|
|
|
|
|
+ Extends,
|
|
|
|
|
+ E,
|
|
|
|
|
+ Readonly<Props>
|
|
|
|
|
+ >
|
|
|
>
|
|
>
|
|
|
|
|
|
|
|
export type ComponentOptionsWithArrayProps<
|
|
export type ComponentOptionsWithArrayProps<
|
|
@@ -162,12 +179,25 @@ export type ComponentOptionsWithArrayProps<
|
|
|
D = {},
|
|
D = {},
|
|
|
C extends ComputedOptions = {},
|
|
C extends ComputedOptions = {},
|
|
|
M extends MethodOptions = {},
|
|
M extends MethodOptions = {},
|
|
|
|
|
+ Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
|
|
|
+ Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
|
E extends EmitsOptions = EmitsOptions,
|
|
E extends EmitsOptions = EmitsOptions,
|
|
|
EE extends string = string,
|
|
EE extends string = string,
|
|
|
Props = Readonly<{ [key in PropNames]?: any }>
|
|
Props = Readonly<{ [key in PropNames]?: any }>
|
|
|
-> = ComponentOptionsBase<Props, RawBindings, D, C, M, E, EE> & {
|
|
|
|
|
|
|
+> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE> & {
|
|
|
props: PropNames[]
|
|
props: PropNames[]
|
|
|
-} & ThisType<ComponentPublicInstance<Props, RawBindings, D, C, M, E>>
|
|
|
|
|
|
|
+} & ThisType<
|
|
|
|
|
+ CreateComponentPublicInstance<
|
|
|
|
|
+ Props,
|
|
|
|
|
+ RawBindings,
|
|
|
|
|
+ D,
|
|
|
|
|
+ C,
|
|
|
|
|
+ M,
|
|
|
|
|
+ Mixin,
|
|
|
|
|
+ Extends,
|
|
|
|
|
+ E
|
|
|
|
|
+ >
|
|
|
|
|
+ >
|
|
|
|
|
|
|
|
export type ComponentOptionsWithObjectProps<
|
|
export type ComponentOptionsWithObjectProps<
|
|
|
PropsOptions = ComponentObjectPropsOptions,
|
|
PropsOptions = ComponentObjectPropsOptions,
|
|
@@ -175,18 +205,43 @@ export type ComponentOptionsWithObjectProps<
|
|
|
D = {},
|
|
D = {},
|
|
|
C extends ComputedOptions = {},
|
|
C extends ComputedOptions = {},
|
|
|
M extends MethodOptions = {},
|
|
M extends MethodOptions = {},
|
|
|
|
|
+ Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
|
|
|
+ Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
|
E extends EmitsOptions = EmitsOptions,
|
|
E extends EmitsOptions = EmitsOptions,
|
|
|
EE extends string = string,
|
|
EE extends string = string,
|
|
|
Props = Readonly<ExtractPropTypes<PropsOptions>>
|
|
Props = Readonly<ExtractPropTypes<PropsOptions>>
|
|
|
-> = ComponentOptionsBase<Props, RawBindings, D, C, M, E, EE> & {
|
|
|
|
|
|
|
+> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE> & {
|
|
|
props: PropsOptions
|
|
props: PropsOptions
|
|
|
-} & ThisType<ComponentPublicInstance<Props, RawBindings, D, C, M, E>>
|
|
|
|
|
|
|
+} & ThisType<
|
|
|
|
|
+ CreateComponentPublicInstance<
|
|
|
|
|
+ Props,
|
|
|
|
|
+ RawBindings,
|
|
|
|
|
+ D,
|
|
|
|
|
+ C,
|
|
|
|
|
+ M,
|
|
|
|
|
+ Mixin,
|
|
|
|
|
+ Extends,
|
|
|
|
|
+ E
|
|
|
|
|
+ >
|
|
|
|
|
+ >
|
|
|
|
|
|
|
|
export type ComponentOptions =
|
|
export type ComponentOptions =
|
|
|
| ComponentOptionsWithoutProps<any, any, any, any, any>
|
|
| ComponentOptionsWithoutProps<any, any, any, any, any>
|
|
|
| ComponentOptionsWithObjectProps<any, any, any, any, any>
|
|
| ComponentOptionsWithObjectProps<any, any, any, any, any>
|
|
|
| ComponentOptionsWithArrayProps<any, any, any, any, any>
|
|
| ComponentOptionsWithArrayProps<any, any, any, any, any>
|
|
|
|
|
|
|
|
|
|
+export type ComponentOptionsMixin = ComponentOptionsBase<
|
|
|
|
|
+ any,
|
|
|
|
|
+ any,
|
|
|
|
|
+ any,
|
|
|
|
|
+ any,
|
|
|
|
|
+ any,
|
|
|
|
|
+ any,
|
|
|
|
|
+ any,
|
|
|
|
|
+ any,
|
|
|
|
|
+ any
|
|
|
|
|
+>
|
|
|
|
|
+
|
|
|
export type ComputedOptions = Record<
|
|
export type ComputedOptions = Record<
|
|
|
string,
|
|
string,
|
|
|
ComputedGetter<any> | WritableComputedOptions<any>
|
|
ComputedGetter<any> | WritableComputedOptions<any>
|
|
@@ -222,7 +277,9 @@ interface LegacyOptions<
|
|
|
Props,
|
|
Props,
|
|
|
D,
|
|
D,
|
|
|
C extends ComputedOptions,
|
|
C extends ComputedOptions,
|
|
|
- M extends MethodOptions
|
|
|
|
|
|
|
+ M extends MethodOptions,
|
|
|
|
|
+ Mixin extends ComponentOptionsMixin,
|
|
|
|
|
+ Extends extends ComponentOptionsMixin
|
|
|
> {
|
|
> {
|
|
|
// allow any custom options
|
|
// allow any custom options
|
|
|
[key: string]: any
|
|
[key: string]: any
|
|
@@ -232,8 +289,8 @@ interface LegacyOptions<
|
|
|
// since that leads to some sort of circular inference and breaks ThisType
|
|
// since that leads to some sort of circular inference and breaks ThisType
|
|
|
// for the entire component.
|
|
// for the entire component.
|
|
|
data?: (
|
|
data?: (
|
|
|
- this: ComponentPublicInstance<Props>,
|
|
|
|
|
- vm: ComponentPublicInstance<Props>
|
|
|
|
|
|
|
+ this: CreateComponentPublicInstance<Props>,
|
|
|
|
|
+ vm: CreateComponentPublicInstance<Props>
|
|
|
) => D
|
|
) => D
|
|
|
computed?: C
|
|
computed?: C
|
|
|
methods?: M
|
|
methods?: M
|
|
@@ -242,8 +299,8 @@ interface LegacyOptions<
|
|
|
inject?: ComponentInjectOptions
|
|
inject?: ComponentInjectOptions
|
|
|
|
|
|
|
|
// composition
|
|
// composition
|
|
|
- mixins?: ComponentOptions[]
|
|
|
|
|
- extends?: ComponentOptions
|
|
|
|
|
|
|
+ mixins?: Mixin[]
|
|
|
|
|
+ extends?: Extends
|
|
|
|
|
|
|
|
// lifecycle
|
|
// lifecycle
|
|
|
beforeCreate?(): void
|
|
beforeCreate?(): void
|
|
@@ -261,6 +318,22 @@ interface LegacyOptions<
|
|
|
errorCaptured?: ErrorCapturedHook
|
|
errorCaptured?: ErrorCapturedHook
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+export type OptionTypesKeys = 'P' | 'B' | 'D' | 'C' | 'M'
|
|
|
|
|
+
|
|
|
|
|
+export type OptionTypesType<
|
|
|
|
|
+ P = {},
|
|
|
|
|
+ B = {},
|
|
|
|
|
+ D = {},
|
|
|
|
|
+ C extends ComputedOptions = {},
|
|
|
|
|
+ M extends MethodOptions = {}
|
|
|
|
|
+> = {
|
|
|
|
|
+ P: P
|
|
|
|
|
+ B: B
|
|
|
|
|
+ D: D
|
|
|
|
|
+ C: C
|
|
|
|
|
+ M: M
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const enum OptionTypes {
|
|
const enum OptionTypes {
|
|
|
PROPS = 'Props',
|
|
PROPS = 'Props',
|
|
|
DATA = 'Data',
|
|
DATA = 'Data',
|