mirror of https://github.com/vuejs/core.git
fix(types): better typing for direct setup signature of defineComponent (#10357)
close #8604 close #8855
This commit is contained in:
parent
a4098d587b
commit
eadce5b753
|
@ -89,6 +89,30 @@ export type DefineComponent<
|
||||||
> &
|
> &
|
||||||
PP
|
PP
|
||||||
|
|
||||||
|
type DirectSetupComponent<
|
||||||
|
P extends Record<string, any>,
|
||||||
|
E extends EmitsOptions = {},
|
||||||
|
S extends SlotsType = SlotsType,
|
||||||
|
Props = P & EmitsToProps<E>,
|
||||||
|
PP = PublicProps,
|
||||||
|
> = new (
|
||||||
|
props: Props & PP,
|
||||||
|
) => CreateComponentPublicInstance<
|
||||||
|
Props,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
ComponentOptionsMixin,
|
||||||
|
ComponentOptionsMixin,
|
||||||
|
E,
|
||||||
|
PP,
|
||||||
|
{},
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
S
|
||||||
|
>
|
||||||
|
|
||||||
// defineComponent is a utility that is primarily used for type inference
|
// defineComponent is a utility that is primarily used for type inference
|
||||||
// when declaring components. Type inference is provided in the component
|
// when declaring components. Type inference is provided in the component
|
||||||
// options (provided as the argument). The returned value has artificial types
|
// options (provided as the argument). The returned value has artificial types
|
||||||
|
@ -111,7 +135,7 @@ export function defineComponent<
|
||||||
emits?: E | EE[]
|
emits?: E | EE[]
|
||||||
slots?: S
|
slots?: S
|
||||||
},
|
},
|
||||||
): (props: Props & EmitsToProps<E>) => any
|
): DirectSetupComponent<Props, E, S>
|
||||||
export function defineComponent<
|
export function defineComponent<
|
||||||
Props extends Record<string, any>,
|
Props extends Record<string, any>,
|
||||||
E extends EmitsOptions = {},
|
E extends EmitsOptions = {},
|
||||||
|
@ -127,7 +151,7 @@ export function defineComponent<
|
||||||
emits?: E | EE[]
|
emits?: E | EE[]
|
||||||
slots?: S
|
slots?: S
|
||||||
},
|
},
|
||||||
): (props: Props & EmitsToProps<E>) => any
|
): DirectSetupComponent<Props, E, S>
|
||||||
|
|
||||||
// overload 2: object format with no props
|
// overload 2: object format with no props
|
||||||
// (uses user defined props interface)
|
// (uses user defined props interface)
|
||||||
|
|
Loading…
Reference in New Issue