Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve type for mount with TS v4.8 #1744

Merged
merged 1 commit into from Aug 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/mount.ts
Expand Up @@ -95,7 +95,7 @@ function getInstanceOptions(
}

// Class component (without vue-class-component) - no props
export function mount<V>(
export function mount<V extends {}>(
originalComponent: {
new (...args: any[]): V
__vccOpts: any
Expand All @@ -104,7 +104,7 @@ export function mount<V>(
): VueWrapper<ComponentPublicInstance<V>>

// Class component (without vue-class-component) - props
export function mount<V, P>(
export function mount<V extends {}, P>(
originalComponent: {
new (...args: any[]): V
__vccOpts: any
Expand All @@ -114,7 +114,7 @@ export function mount<V, P>(
): VueWrapper<ComponentPublicInstance<V>>

// Class component - no props
export function mount<V>(
export function mount<V extends {}>(
originalComponent: {
new (...args: any[]): V
registerHooks(keys: string[]): void
Expand All @@ -123,7 +123,7 @@ export function mount<V>(
): VueWrapper<ComponentPublicInstance<V>>

// Class component - props
export function mount<V, P>(
export function mount<V extends {}, P>(
originalComponent: {
new (...args: any[]): V
props(Props: P): any
Expand All @@ -133,7 +133,7 @@ export function mount<V, P>(
): VueWrapper<ComponentPublicInstance<V>>

// Functional component with emits
export function mount<Props, E extends EmitsOptions = {}>(
export function mount<Props extends {}, E extends EmitsOptions = {}>(
originalComponent: FunctionalComponent<Props, E>,
options?: MountingOptions<Props & PublicProps> & Record<string, any>
): VueWrapper<ComponentPublicInstance<Props>>
Expand All @@ -151,7 +151,7 @@ export function mount<
EE extends string = string,
PP = PublicProps,
Props = Readonly<ExtractPropTypes<PropsOrPropOptions>>,
Defaults = ExtractDefaultPropTypes<PropsOrPropOptions>
Defaults extends {} = ExtractDefaultPropTypes<PropsOrPropOptions>
>(
component: DefineComponent<
PropsOrPropOptions,
Expand Down Expand Up @@ -200,7 +200,7 @@ export function mount<T extends DefineComponent<any, any, any, any>>(
export function mount<
Props = {},
RawBindings = {},
D = {},
D extends {} = {},
C extends ComputedOptions = {},
M extends Record<string, Function> = {},
E extends EmitsOptions = Record<string, any>,
Expand Down Expand Up @@ -229,7 +229,7 @@ export function mount<
export function mount<
PropNames extends string,
RawBindings,
D,
D extends {},
C extends ComputedOptions = {},
M extends Record<string, Function> = {},
E extends EmitsOptions = Record<string, any>,
Expand Down Expand Up @@ -261,7 +261,7 @@ export function mount<
// as constant instead of boolean.
PropsOptions extends Readonly<ComponentPropsOptions>,
RawBindings,
D,
D extends {},
C extends ComputedOptions = {},
M extends Record<string, Function> = {},
E extends EmitsOptions = Record<string, any>,
Expand Down