Skip to content

Commit eadce5b

Browse files
authoredFeb 25, 2024··
fix(types): better typing for direct setup signature of defineComponent (#10357)
close #8604 close #8855
1 parent a4098d5 commit eadce5b

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed
 

‎packages/runtime-core/src/apiDefineComponent.ts

+26-2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,30 @@ export type DefineComponent<
8989
> &
9090
PP
9191

92+
type DirectSetupComponent<
93+
P extends Record<string, any>,
94+
E extends EmitsOptions = {},
95+
S extends SlotsType = SlotsType,
96+
Props = P & EmitsToProps<E>,
97+
PP = PublicProps,
98+
> = new (
99+
props: Props & PP,
100+
) => CreateComponentPublicInstance<
101+
Props,
102+
{},
103+
{},
104+
{},
105+
{},
106+
ComponentOptionsMixin,
107+
ComponentOptionsMixin,
108+
E,
109+
PP,
110+
{},
111+
false,
112+
{},
113+
S
114+
>
115+
92116
// defineComponent is a utility that is primarily used for type inference
93117
// when declaring components. Type inference is provided in the component
94118
// options (provided as the argument). The returned value has artificial types
@@ -111,7 +135,7 @@ export function defineComponent<
111135
emits?: E | EE[]
112136
slots?: S
113137
},
114-
): (props: Props & EmitsToProps<E>) => any
138+
): DirectSetupComponent<Props, E, S>
115139
export function defineComponent<
116140
Props extends Record<string, any>,
117141
E extends EmitsOptions = {},
@@ -127,7 +151,7 @@ export function defineComponent<
127151
emits?: E | EE[]
128152
slots?: S
129153
},
130-
): (props: Props & EmitsToProps<E>) => any
154+
): DirectSetupComponent<Props, E, S>
131155

132156
// overload 2: object format with no props
133157
// (uses user defined props interface)

0 commit comments

Comments
 (0)
Please sign in to comment.