From 4b37b568c7c3fd238aa61fcc956f882223f8e87f Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 15 Aug 2022 09:53:12 +0800 Subject: [PATCH] fix(types): fix options suggestions when using defineComponent functional component overloads should be moved last fix #12736 --- types/v3-define-component.d.ts | 56 +++++++++++++++++----------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/types/v3-define-component.d.ts b/types/v3-define-component.d.ts index 30f7046e40..a2c47322b4 100644 --- a/types/v3-define-component.d.ts +++ b/types/v3-define-component.d.ts @@ -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) => any -}): DefineComponent - -/** - * overload 0.1: functional component with object props - */ -export function defineComponent< - PropsOptions extends ComponentPropsOptions = ComponentPropsOptions, - Props = ExtractPropTypes ->(options: { - functional: true - props?: PropsOptions - render?: (h: CreateElement, context: RenderContext) => any -}): DefineComponent - /** * 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 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 + +/** + * 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) => any +}): DefineComponent + +/** + * overload 4.2: functional component with object props + */ +export function defineComponent< + PropsOptions extends ComponentPropsOptions = ComponentPropsOptions, + Props = ExtractPropTypes +>(options: { + functional: true + props?: PropsOptions + render?: (h: CreateElement, context: RenderContext) => any +}): DefineComponent