Open
Description
Subject of the issue
After updating vue
to 2.7.9 or above, vue-tsc
throws an type error on the mount()
call.
Seems triggered by https://github.com/vuejs/vue/pull/12727/files
Steps to reproduce
pnpm create vue@2 --typescript --vitest vue2-test-utils-type-checking
cd vue2-test-utils-type-checking
pnpm i
pnpm type-check
Expected behaviour
The type-checking should succeed without errors.
Actual behaviour
src/components/__tests__/HelloWorld.spec.ts:8:27 - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'ComponentPublicInstanceConstructor<Vue3Instance<{}, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{ msg: string; }>>>, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{ msg: string; }>>>, {}, {}, true, ComponentOptionsBase<...>> & ... 4 more ... & Readonly<...>, ... 4 more ..., MethodOptions> & Com...' is not assignable to parameter of type 'ExtendedVue<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, ...>>, ... 6 more ..., ComponentOptionsMixin>'.
Type 'ComponentPublicInstanceConstructor<Vue3Instance<{}, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{ msg: string; }>>>, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{ msg: string; }>>>, {}, {}, true, ComponentOptionsBase<...>> & ... 4 more ... & Readonly<...>, ... 4 more ..., MethodOptions> & Com...' is missing the following properties from type 'VueConstructor<ExtractComputedReturns<{}> & DefaultProps & Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<...>> & ShallowUnwrapRef<...> & Vue<...>>': extend, nextTick, set, delete, and 10 more.
8 const wrapper = mount(HelloWorld, { propsData: { msg: 'Hello Vitest' } })
~~~~~~~~~~
node_modules/.pnpm/@vue+test-utils@1.3.3_2s2ymob7v2oigx3hqbmnjuqthq/node_modules/@vue/test-utils/types/index.d.ts:195:25
195 export declare function mount<V extends Vue, Props = DefaultProps> (component: ExtendedVue<V, {}, {}, {}, Props>, options?: FunctionalComponentMountOptions<V>): Wrapper<CombinedVueInstance<V, {}, {}, {}, Props> & Vue>
~~~~~
The last overload is declared here.
Found 1 error in src/components/__tests__/HelloWorld.spec.ts:8
Possible Solution
I don't know…