Skip to content

Commit 4b37b56

Browse files
committed
fix(types): fix options suggestions when using defineComponent
functional component overloads should be moved last fix #12736
1 parent 5c742eb commit 4b37b56

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

types/v3-define-component.d.ts

+28-28
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,6 @@ type DefineComponent<
6767
props: PropsOrPropOptions
6868
}
6969

70-
/**
71-
* overload 0.0: functional component with array props
72-
*/
73-
export function defineComponent<
74-
PropNames extends string,
75-
Props = Readonly<{ [key in PropNames]?: any }>
76-
>(options: {
77-
functional: true
78-
props?: PropNames[]
79-
render?: (h: CreateElement, context: RenderContext<Props>) => any
80-
}): DefineComponent<Props>
81-
82-
/**
83-
* overload 0.1: functional component with object props
84-
*/
85-
export function defineComponent<
86-
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions,
87-
Props = ExtractPropTypes<PropsOptions>
88-
>(options: {
89-
functional: true
90-
props?: PropsOptions
91-
render?: (h: CreateElement, context: RenderContext<Props>) => any
92-
}): DefineComponent<PropsOptions>
93-
9470
/**
9571
* overload 1: object format with no props
9672
*/
@@ -104,7 +80,7 @@ export function defineComponent<
10480
Emits extends EmitsOptions = {},
10581
EmitsNames extends string = string
10682
>(
107-
options: ComponentOptionsWithoutProps<
83+
options: { functional?: never } & ComponentOptionsWithoutProps<
10884
{},
10985
RawBindings,
11086
D,
@@ -135,7 +111,7 @@ export function defineComponent<
135111
EmitsNames extends string = string,
136112
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
137113
>(
138-
options: ComponentOptionsWithArrayProps<
114+
options: { functional?: never } & ComponentOptionsWithArrayProps<
139115
PropNames,
140116
RawBindings,
141117
D,
@@ -175,7 +151,7 @@ export function defineComponent<
175151
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
176152
>(
177153
options: HasDefined<Props> extends true
178-
? ComponentOptionsWithProps<
154+
? { functional?: never } & ComponentOptionsWithProps<
179155
PropsOptions,
180156
RawBindings,
181157
D,
@@ -187,7 +163,7 @@ export function defineComponent<
187163
EmitsNames,
188164
Props
189165
>
190-
: ComponentOptionsWithProps<
166+
: { functional?: never } & ComponentOptionsWithProps<
191167
PropsOptions,
192168
RawBindings,
193169
D,
@@ -199,3 +175,27 @@ export function defineComponent<
199175
EmitsNames
200176
>
201177
): DefineComponent<PropsOptions, RawBindings, D, C, M, Mixin, Extends, Emits>
178+
179+
/**
180+
* overload 4.1: functional component with array props
181+
*/
182+
export function defineComponent<
183+
PropNames extends string,
184+
Props = Readonly<{ [key in PropNames]?: any }>
185+
>(options: {
186+
functional: true
187+
props?: PropNames[]
188+
render?: (h: CreateElement, context: RenderContext<Props>) => any
189+
}): DefineComponent<Props>
190+
191+
/**
192+
* overload 4.2: functional component with object props
193+
*/
194+
export function defineComponent<
195+
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions,
196+
Props = ExtractPropTypes<PropsOptions>
197+
>(options: {
198+
functional: true
199+
props?: PropsOptions
200+
render?: (h: CreateElement, context: RenderContext<Props>) => any
201+
}): DefineComponent<PropsOptions>

0 commit comments

Comments
 (0)