Skip to content

Commit

Permalink
fix(types): fix options suggestions when using defineComponent
Browse files Browse the repository at this point in the history
functional component overloads should be moved last

fix #12736
  • Loading branch information
yyx990803 committed Aug 15, 2022
1 parent 5c742eb commit 4b37b56
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions types/v3-define-component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -104,7 +80,7 @@ export function defineComponent<
Emits extends EmitsOptions = {},
EmitsNames extends string = string
>(
options: ComponentOptionsWithoutProps<
options: { functional?: never } & ComponentOptionsWithoutProps<
{},
RawBindings,
D,
Expand Down Expand Up @@ -135,7 +111,7 @@ export function defineComponent<
EmitsNames extends string = string,
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
>(
options: ComponentOptionsWithArrayProps<
options: { functional?: never } & ComponentOptionsWithArrayProps<
PropNames,
RawBindings,
D,
Expand Down Expand Up @@ -175,7 +151,7 @@ export function defineComponent<
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
>(
options: HasDefined<Props> extends true
? ComponentOptionsWithProps<
? { functional?: never } & ComponentOptionsWithProps<
PropsOptions,
RawBindings,
D,
Expand All @@ -187,7 +163,7 @@ export function defineComponent<
EmitsNames,
Props
>
: ComponentOptionsWithProps<
: { functional?: never } & ComponentOptionsWithProps<
PropsOptions,
RawBindings,
D,
Expand All @@ -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>

0 comments on commit 4b37b56

Please sign in to comment.