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: refactor and remove old files #1776

Merged
merged 2 commits into from Sep 19, 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
40 changes: 20 additions & 20 deletions src/mount.ts
Expand Up @@ -45,8 +45,6 @@ import { trackInstance } from './utils/autoUnmount'
import { createVueWrapper } from './wrapperFactory'

// NOTE this should come from `vue`
type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps

const MOUNT_OPTIONS: Array<keyof MountingOptions<any>> = [
'attachTo',
'attrs',
Expand All @@ -57,24 +55,6 @@ const MOUNT_OPTIONS: Array<keyof MountingOptions<any>> = [
'shallow'
]

type ComponentMountingOptions<T> = T extends DefineComponent<
infer PropsOrPropOptions,
any,
infer D,
any,
any
>
? MountingOptions<
Partial<ExtractDefaultPropTypes<PropsOrPropOptions>> &
Omit<
Readonly<ExtractPropTypes<PropsOrPropOptions>> & PublicProps,
keyof ExtractDefaultPropTypes<PropsOrPropOptions>
>,
D
> &
Record<string, any>
: MountingOptions<any>

function getInstanceOptions(
options: MountingOptions<any> & Record<string, any>
): Record<string, any> {
Expand All @@ -94,6 +74,26 @@ function getInstanceOptions(
return resultOptions
}

type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps

type ComponentMountingOptions<T> = T extends DefineComponent<
infer PropsOrPropOptions,
any,
infer D,
any,
any
>
? MountingOptions<
Partial<ExtractDefaultPropTypes<PropsOrPropOptions>> &
Omit<
Readonly<ExtractPropTypes<PropsOrPropOptions>> & PublicProps,
keyof ExtractDefaultPropTypes<PropsOrPropOptions>
>,
D
> &
Record<string, any>
: MountingOptions<any>

// Class component (without vue-class-component) - no props
export function mount<V extends {}>(
originalComponent: {
Expand Down