fix(types): fix options suggestions when using defineComponent

functional component overloads should be moved last

fix #12736
This commit is contained in:
Evan You 2022-08-15 09:53:12 +08:00
parent 5c742eb2e0
commit 4b37b568c7

View File

@ -67,30 +67,6 @@ type DefineComponent<
props: PropsOrPropOptions
}
/**
* overload 0.0: functional component with array props
*/
export function defineComponent<
PropNames extends string,
Props = Readonly<{ [key in PropNames]?: any }>
>(options: {
functional: true
props?: PropNames[]
render?: (h: CreateElement, context: RenderContext<Props>) => any
}): DefineComponent<Props>
/**
* overload 0.1: functional component with object props
*/
export function defineComponent<
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions,
Props = ExtractPropTypes<PropsOptions>
>(options: {
functional: true
props?: PropsOptions
render?: (h: CreateElement, context: RenderContext<Props>) => any
}): DefineComponent<PropsOptions>
/**
* overload 1: object format with no props
*/
@ -104,7 +80,7 @@ export function defineComponent<
Emits extends EmitsOptions = {},
EmitsNames extends string = string
>(
options: ComponentOptionsWithoutProps<
options: { functional?: never } & ComponentOptionsWithoutProps<
{},
RawBindings,
D,
@ -135,7 +111,7 @@ export function defineComponent<
EmitsNames extends string = string,
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
>(
options: ComponentOptionsWithArrayProps<
options: { functional?: never } & ComponentOptionsWithArrayProps<
PropNames,
RawBindings,
D,
@ -175,7 +151,7 @@ export function defineComponent<
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
>(
options: HasDefined<Props> extends true
? ComponentOptionsWithProps<
? { functional?: never } & ComponentOptionsWithProps<
PropsOptions,
RawBindings,
D,
@ -187,7 +163,7 @@ export function defineComponent<
EmitsNames,
Props
>
: ComponentOptionsWithProps<
: { functional?: never } & ComponentOptionsWithProps<
PropsOptions,
RawBindings,
D,
@ -199,3 +175,27 @@ export function defineComponent<
EmitsNames
>
): DefineComponent<PropsOptions, RawBindings, D, C, M, Mixin, Extends, Emits>
/**
* overload 4.1: functional component with array props
*/
export function defineComponent<
PropNames extends string,
Props = Readonly<{ [key in PropNames]?: any }>
>(options: {
functional: true
props?: PropNames[]
render?: (h: CreateElement, context: RenderContext<Props>) => any
}): DefineComponent<Props>
/**
* overload 4.2: functional component with object props
*/
export function defineComponent<
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions,
Props = ExtractPropTypes<PropsOptions>
>(options: {
functional: true
props?: PropsOptions
render?: (h: CreateElement, context: RenderContext<Props>) => any
}): DefineComponent<PropsOptions>