|
|
@@ -28,6 +28,7 @@ import {
|
|
|
CreateComponentPublicInstance,
|
|
|
ComponentPublicInstanceConstructor
|
|
|
} from './componentPublicInstance'
|
|
|
+import { SlotsType } from './componentSlots'
|
|
|
|
|
|
export type PublicProps = VNodeProps &
|
|
|
AllowedComponentProps &
|
|
|
@@ -43,6 +44,7 @@ export type DefineComponent<
|
|
|
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
|
E extends EmitsOptions = {},
|
|
|
EE extends string = string,
|
|
|
+ S extends SlotsType = {},
|
|
|
PP = PublicProps,
|
|
|
Props = Readonly<
|
|
|
PropsOrPropOptions extends ComponentPropsOptions
|
|
|
@@ -61,6 +63,7 @@ export type DefineComponent<
|
|
|
Mixin,
|
|
|
Extends,
|
|
|
E,
|
|
|
+ S,
|
|
|
PP & Props,
|
|
|
Defaults,
|
|
|
true
|
|
|
@@ -77,6 +80,7 @@ export type DefineComponent<
|
|
|
Extends,
|
|
|
E,
|
|
|
EE,
|
|
|
+ S,
|
|
|
Defaults
|
|
|
> &
|
|
|
PP
|
|
|
@@ -91,29 +95,33 @@ export type DefineComponent<
|
|
|
export function defineComponent<
|
|
|
Props extends Record<string, any>,
|
|
|
E extends EmitsOptions = {},
|
|
|
- EE extends string = string
|
|
|
+ EE extends string = string,
|
|
|
+ S extends SlotsType = {}
|
|
|
>(
|
|
|
setup: (
|
|
|
props: Props,
|
|
|
- ctx: SetupContext<E>
|
|
|
+ ctx: SetupContext<E, S>
|
|
|
) => RenderFunction | Promise<RenderFunction>,
|
|
|
options?: Pick<ComponentOptions, 'name' | 'inheritAttrs'> & {
|
|
|
props?: (keyof Props)[]
|
|
|
emits?: E | EE[]
|
|
|
+ slots?: S
|
|
|
}
|
|
|
): (props: Props & EmitsToProps<E>) => any
|
|
|
export function defineComponent<
|
|
|
Props extends Record<string, any>,
|
|
|
E extends EmitsOptions = {},
|
|
|
- EE extends string = string
|
|
|
+ EE extends string = string,
|
|
|
+ S extends SlotsType = {}
|
|
|
>(
|
|
|
setup: (
|
|
|
props: Props,
|
|
|
- ctx: SetupContext<E>
|
|
|
+ ctx: SetupContext<E, S>
|
|
|
) => RenderFunction | Promise<RenderFunction>,
|
|
|
options?: Pick<ComponentOptions, 'name' | 'inheritAttrs'> & {
|
|
|
props?: ComponentObjectPropsOptions<Props>
|
|
|
emits?: E | EE[]
|
|
|
+ slots?: S
|
|
|
}
|
|
|
): (props: Props & EmitsToProps<E>) => any
|
|
|
|
|
|
@@ -130,6 +138,7 @@ export function defineComponent<
|
|
|
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
|
E extends EmitsOptions = {},
|
|
|
EE extends string = string,
|
|
|
+ S extends SlotsType = {},
|
|
|
I extends ComponentInjectOptions = {},
|
|
|
II extends string = string
|
|
|
>(
|
|
|
@@ -143,10 +152,11 @@ export function defineComponent<
|
|
|
Extends,
|
|
|
E,
|
|
|
EE,
|
|
|
+ S,
|
|
|
I,
|
|
|
II
|
|
|
>
|
|
|
-): DefineComponent<Props, RawBindings, D, C, M, Mixin, Extends, E, EE>
|
|
|
+): DefineComponent<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, S>
|
|
|
|
|
|
// overload 3: object format with array props declaration
|
|
|
// props inferred as { [key in PropNames]?: any }
|
|
|
@@ -161,6 +171,7 @@ export function defineComponent<
|
|
|
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
|
E extends EmitsOptions = {},
|
|
|
EE extends string = string,
|
|
|
+ S extends SlotsType = {},
|
|
|
I extends ComponentInjectOptions = {},
|
|
|
II extends string = string
|
|
|
>(
|
|
|
@@ -174,6 +185,7 @@ export function defineComponent<
|
|
|
Extends,
|
|
|
E,
|
|
|
EE,
|
|
|
+ S,
|
|
|
I,
|
|
|
II
|
|
|
>
|
|
|
@@ -186,7 +198,8 @@ export function defineComponent<
|
|
|
Mixin,
|
|
|
Extends,
|
|
|
E,
|
|
|
- EE
|
|
|
+ EE,
|
|
|
+ S
|
|
|
>
|
|
|
|
|
|
// overload 4: object format with object props declaration
|
|
|
@@ -203,6 +216,7 @@ export function defineComponent<
|
|
|
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
|
|
|
E extends EmitsOptions = {},
|
|
|
EE extends string = string,
|
|
|
+ S extends SlotsType = {},
|
|
|
I extends ComponentInjectOptions = {},
|
|
|
II extends string = string
|
|
|
>(
|
|
|
@@ -216,10 +230,11 @@ export function defineComponent<
|
|
|
Extends,
|
|
|
E,
|
|
|
EE,
|
|
|
+ S,
|
|
|
I,
|
|
|
II
|
|
|
>
|
|
|
-): DefineComponent<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE>
|
|
|
+): DefineComponent<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, S>
|
|
|
|
|
|
// implementation, close to no-op
|
|
|
export function defineComponent(
|