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

mount and shallowMount do not type check with vue 2.7.x #1993

Open
dten opened this issue Aug 3, 2022 · 1 comment
Open

mount and shallowMount do not type check with vue 2.7.x #1993

dten opened this issue Aug 3, 2022 · 1 comment

Comments

@dten
Copy link

dten commented Aug 3, 2022

Subject of the issue

type checking when using vue-utils when using vue 2.7.8 fails because an extra argument was added to the vue types

node_modules/@vue/test-utils/types/index.d.ts:193:80 - error TS2314: Generic type 'ExtendedVue' requires 6 type argument(s).

193 export declare function mount<V extends Vue, Props = DefaultProps> (component: ExtendedVue<V, {}, {}, {}, Props>, options?: FunctionalComponentMountOptions<V>): Wrapper<CombinedVueInstance<V, {}, {}, {}, Props> & Vue>
                                                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@vue/test-utils/types/index.d.ts:193:170 - error TS2314: Generic type 'CombinedVueInstance' requires 6 type argument(s).

193 export declare function mount<V extends Vue, Props = DefaultProps> (component: ExtendedVue<V, {}, {}, {}, Props>, options?: FunctionalComponentMountOptions<V>): Wrapper<CombinedVueInstance<V, {}, {}, {}, Props> & Vue>
                                                                                                                                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@vue/test-utils/types/index.d.ts:197:97 - error TS2314: Generic type 'ExtendedVue' requires 6 type argument(s).

197 export declare function shallowMount<V extends Vue, Data, Methods, Computed, Props> (component: ExtendedVue<V, Data, Methods, Computed, Props>, options?: ThisTypedShallowMountOptions<V>): Wrapper<CombinedVueInstance<V, Data, Methods, Computed, Props> & Vue>
                                                                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@vue/test-utils/types/index.d.ts:197:197 - error TS2314: Generic type 'CombinedVueInstance' requires 6 type argument(s).

197 export declare function shallowMount<V extends Vue, Data, Methods, Computed, Props> (component: ExtendedVue<V, Data, Methods, Computed, Props>, options?: ThisTypedShallowMountOptions<V>): Wrapper<CombinedVueInstance<V, Data, Methods, Computed, Props> & Vue>
                                                                                                                                                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Steps to reproduce

in this repo upgrade vue, vue-template-compiler and typescript (needed to parse the vue d.ts files) then yarn test:types

Expected behaviour

should be compatible

Actual behaviour

❯ yarn test:types
yarn run v1.22.19
$ tsc -p packages/test-utils/types && tsc -p packages/server-test-utils/types
packages/test-utils/types/index.d.ts:191:90 - error TS2314: Generic type 'ExtendedVue' requires 6 type argument(s).

191 export declare function mount<V extends Vue, Data, Methods, Computed, Props> (component: ExtendedVue<V, Data, Methods, Computed, Props>, options?: ThisTypedMountOptions<V>): Wrapper<CombinedVueInstance<V, Data, Methods, Computed, Props> & Vue>
                                                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

packages/test-utils/types/index.d.ts:191:183 - error TS2314: Generic type 'CombinedVueInstance' requires 6 type argument(s).

191 export declare function mount<V extends Vue, Data, Methods, Computed, Props> (component: ExtendedVue<V, Data, Methods, Computed, Props>, options?: ThisTypedMountOptions<V>): Wrapper<CombinedVueInstance<V, Data, Methods, Computed, Props> & Vue>
                                                                                                                                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

packages/test-utils/types/index.d.ts:193:80 - error TS2314: Generic type 'ExtendedVue' requires 6 type argument(s).

193 export declare function mount<V extends Vue, Props = DefaultProps> (component: ExtendedVue<V, {}, {}, {}, Props>, options?: FunctionalComponentMountOptions<V>): Wrapper<CombinedVueInstance<V, {}, {}, {}, Props> & Vue>
                                                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

packages/test-utils/types/index.d.ts:193:170 - error TS2314: Generic type 'CombinedVueInstance' requires 6 type argument(s).

193 export declare function mount<V extends Vue, Props = DefaultProps> (component: ExtendedVue<V, {}, {}, {}, Props>, options?: FunctionalComponentMountOptions<V>): Wrapper<CombinedVueInstance<V, {}, {}, {}, Props> & Vue>
                                                                                                                                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

packages/test-utils/types/index.d.ts:197:97 - error TS2314: Generic type 'ExtendedVue' requires 6 type argument(s).

197 export declare function shallowMount<V extends Vue, Data, Methods, Computed, Props> (component: ExtendedVue<V, Data, Methods, Computed, Props>, options?: ThisTypedShallowMountOptions<V>): Wrapper<CombinedVueInstance<V, Data, Methods, Computed, Props> & Vue>
                                                                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

packages/test-utils/types/index.d.ts:197:197 - error TS2314: Generic type 'CombinedVueInstance' requires 6 type argument(s).

197 export declare function shallowMount<V extends Vue, Data, Methods, Computed, Props> (component: ExtendedVue<V, Data, Methods, Computed, Props>, options?: ThisTypedShallowMountOptions<V>): Wrapper<CombinedVueInstance<V, Data, Methods, Computed, Props> & Vue>
                                                                                                                                                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

packages/test-utils/types/index.d.ts:199:87 - error TS2314: Generic type 'ExtendedVue' requires 6 type argument(s).

199 export declare function shallowMount<V extends Vue, Props = DefaultProps> (component: ExtendedVue<V, {}, {}, {}, Props>, options?: FunctionalComponentShallowMountOptions<V>): Wrapper<CombinedVueInstance<V, {}, {}, {}, Props> & Vue>
                                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

packages/test-utils/types/index.d.ts:199:184 - error TS2314: Generic type 'CombinedVueInstance' requires 6 type argument(s).

199 export declare function shallowMount<V extends Vue, Props = DefaultProps> (component: ExtendedVue<V, {}, {}, {}, Props>, options?: FunctionalComponentShallowMountOptions<V>): Wrapper<CombinedVueInstance<V, {}, {}, {}, Props> & Vue>
                                                                                                                                                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

packages/test-utils/types/test/mount.ts:86:10 - error TS2339: Property 'bar' does not exist on type 'Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, ...>>'.

86     this.bar
            ~~~

packages/test-utils/types/test/shallow.ts:77:10 - error TS2339: Property 'bar' does not exist on type 'Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, ...>>'.

77     this.bar
            ~~~


Found 10 errors in 3 files.

Possible Solution

some changes to support latest vue 2

@dten dten changed the title mount and shallowMount do not type check with vue 2.7.3 mount and shallowMount do not type check with vue 2.7.8 Aug 3, 2022
@dten dten changed the title mount and shallowMount do not type check with vue 2.7.8 mount and shallowMount do not type check with vue 2.7.x Aug 3, 2022
gbirke added a commit to wmde/fundraising-application that referenced this issue Nov 5, 2022
One of the recent dependency updates (commit
c04d946) has introduced a lot of errors
for TypeScript components in the tests. By temporarily removing the test directory
from the includes, the type checker won't check the `tests` directory.

This is a stopgap measure until the underlying cause has been fixed.
You should revert this commit when
vuejs/vue-test-utils#1993 has been fixed.
@ColinRosati
Copy link

I havent tried your setup, but had a similar issue with my TS compiler plaining about the components passed into shallowMount/mount.

I did a little type casting to get it working

import { Component } from "vue"
const testComponent: Component = <YourComponent>;
mount(testComponent, {...})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants