Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions packages/runtime-core/src/apiDefineComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,30 @@ export type DefineComponent<
> &
PP

type DirectSetupComponent<
P extends Record<string, any>,
E extends EmitsOptions = {},
S extends SlotsType = SlotsType,
Props = P & EmitsToProps<E>,
PP = PublicProps,
> = new (
props: Props & PP,
) => CreateComponentPublicInstance<
Props,
{},
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
E,
PP,
{},
false,
{},
S
>

// defineComponent is a utility that is primarily used for type inference
// when declaring components. Type inference is provided in the component
// options (provided as the argument). The returned value has artificial types
Expand All @@ -111,7 +135,7 @@ export function defineComponent<
emits?: E | EE[]
slots?: S
},
): (props: Props & EmitsToProps<E>) => any
): DirectSetupComponent<Props, E, S>
export function defineComponent<
Props extends Record<string, any>,
E extends EmitsOptions = {},
Expand All @@ -127,7 +151,7 @@ export function defineComponent<
emits?: E | EE[]
slots?: S
},
): (props: Props & EmitsToProps<E>) => any
): DirectSetupComponent<Props, E, S>

// overload 2: object format with no props
// (uses user defined props interface)
Expand Down