Skip to content

Commit ebcf97c

Browse files
authored
fix: improvement functional component features (#1427)
1 parent a4e077c commit ebcf97c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Diff for: packages/server-test-utils/types/index.d.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Vue, { VNodeData, ComponentOptions, FunctionalComponentOptions, Component } from 'vue'
2+
import { DefaultProps, PropsDefinition } from 'vue/types/options'
23

34
/**
45
* Utility type to declare an extended Vue constructor
@@ -50,8 +51,8 @@ export declare let config: VueTestUtilsConfigOptions
5051

5152
export declare function render<V extends Vue> (component: VueClass<V>, options?: ThisTypedMountOptions<V>): Promise<Cheerio>
5253
export declare function render<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedMountOptions<V>): Promise<Cheerio>
53-
export declare function render (component: FunctionalComponentOptions, options?: MountOptions<Vue>): Promise<Cheerio>
54+
export declare function render<Props = DefaultProps, PropDefs = PropsDefinition<Props>>(component: FunctionalComponentOptions<Props, PropDefs>, options?: MountOptions<Vue>): Promise<Cheerio>
5455

5556
export declare function renderToString<V extends Vue> (component: VueClass<V>, options?: ThisTypedMountOptions<V>): Promise<string>
5657
export declare function renderToString<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedMountOptions<V>): Promise<string>
57-
export declare function renderToString (component: FunctionalComponentOptions, options?: MountOptions<Vue>): Promise<string>
58+
export declare function renderToString<Props = DefaultProps, PropDefs = PropsDefinition<Props>>(component: FunctionalComponentOptions<Props, PropDefs>, options?: MountOptions<Vue>): Promise<string>

Diff for: packages/test-utils/types/index.d.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Vue, { VNodeData, ComponentOptions, FunctionalComponentOptions, Component } from 'vue'
2+
import { DefaultProps, PropsDefinition } from 'vue/types/options'
23

34
/**
45
* Utility type to declare an extended Vue constructor
@@ -79,21 +80,21 @@ export interface Wrapper<V extends Vue | null> extends BaseWrapper {
7980

8081
get<R extends Vue> (selector: VueClass<R>): Wrapper<R>
8182
get<R extends Vue> (selector: ComponentOptions<R>): Wrapper<R>
82-
get (selector: FunctionalComponentOptions): Wrapper<Vue>
83+
get<Props = DefaultProps, PropDefs = PropsDefinition<Props>>(selector: FunctionalComponentOptions<Props, PropDefs>): Wrapper<Vue>
8384
get (selector: string): Wrapper<Vue>
8485
get (selector: RefSelector): Wrapper<Vue>
8586
get (selector: NameSelector): Wrapper<Vue>
8687

8788
find<R extends Vue> (selector: VueClass<R>): Wrapper<R>
8889
find<R extends Vue> (selector: ComponentOptions<R>): Wrapper<R>
89-
find (selector: FunctionalComponentOptions): Wrapper<Vue>
90+
find<Props = DefaultProps, PropDefs = PropsDefinition<Props>>(selector: FunctionalComponentOptions<Props, PropDefs>): Wrapper<Vue>
9091
find (selector: string): Wrapper<Vue>
9192
find (selector: RefSelector): Wrapper<Vue>
9293
find (selector: NameSelector): Wrapper<Vue>
9394

9495
findAll<R extends Vue> (selector: VueClass<R>): WrapperArray<R>
9596
findAll<R extends Vue> (selector: ComponentOptions<R>): WrapperArray<R>
96-
findAll (selector: FunctionalComponentOptions): WrapperArray<Vue>
97+
findAll<Props = DefaultProps, PropDefs = PropsDefinition<Props>>(selector: FunctionalComponentOptions<Props, PropDefs>): WrapperArray<Vue>
9798
findAll (selector: string): WrapperArray<Vue>
9899
findAll (selector: RefSelector): WrapperArray<Vue>
99100
findAll (selector: NameSelector): WrapperArray<Vue>
@@ -157,11 +158,11 @@ export declare let config: VueTestUtilsConfigOptions
157158

158159
export declare function mount<V extends Vue> (component: VueClass<V>, options?: ThisTypedMountOptions<V>): Wrapper<V>
159160
export declare function mount<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedMountOptions<V>): Wrapper<V>
160-
export declare function mount (component: FunctionalComponentOptions, options?: MountOptions<Vue>): Wrapper<Vue>
161+
export declare function mount<Props = DefaultProps, PropDefs = PropsDefinition<Props>>(component: FunctionalComponentOptions<Props, PropDefs>, options?: MountOptions<Vue>): Wrapper<Vue>
161162

162163
export declare function shallowMount<V extends Vue> (component: VueClass<V>, options?: ThisTypedShallowMountOptions<V>): Wrapper<V>
163164
export declare function shallowMount<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedShallowMountOptions<V>): Wrapper<V>
164-
export declare function shallowMount (component: FunctionalComponentOptions, options?: ShallowMountOptions<Vue>): Wrapper<Vue>
165+
export declare function shallowMount<Props = DefaultProps, PropDefs = PropsDefinition<Props>>(component: FunctionalComponentOptions<Props, PropDefs>, options?: ShallowMountOptions<Vue>): Wrapper<Vue>
165166

166167
export declare function createWrapper(node: Vue, options?: WrapperOptions): Wrapper<Vue>
167168
export declare function createWrapper(node: HTMLElement, options?: WrapperOptions): Wrapper<null>

0 commit comments

Comments
 (0)