Skip to content

Commit

Permalink
chore: refactor mount types (#1776)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiller1990 committed Sep 19, 2022
1 parent 43bc117 commit 2deb954
Showing 1 changed file with 20 additions and 20 deletions.
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

0 comments on commit 2deb954

Please sign in to comment.