SetupBindings in vue.d.ts should be optional

This issue has been tracked since 2022-07-29.

Version

2.7.8

Reproduction link

stackblitz.com

Steps to reproduce

run npx tsc in terminal.

You will get following error message:

comp-26/dist/message.d.ts:2:32 - error TS2314: Generic type 'ExtendedVue' requires 6 type argument(s).

  2 export declare const vMessage: import('vue/types/vue').ExtendedVue<
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3   Vue,
    ~~~~~~
... 
  9   Record<never, any>
    ~~~~~~~~~~~~~~~~~~~~
 10 >;
    ~


Found 1 error in comp-26/dist/message.d.ts:2

What is expected?

Pass the type checking.

What is actually happening?

I use a Vue component library with Typescript in my project. The component from the library is built on Vue 2.6.

Vue 2.7 changed the vue.d.ts, the type definition generated by Vue 2.6 is not compatible with 2.7.

message.js

import Vue from 'vue';
export const vMessage = Vue.extend({
  data: {
    message: 'Hello Vue v2.6!',
  },
  template: '<div>{{ message }}</div>',
});

message.d.ts

import Vue from 'vue';
export declare const vMessage: import('vue/types/vue').ExtendedVue<
  Vue,
  {
    message: string;
  },
  unknown,
  unknown,
  Record<never, any>
>;

There are 6 type parameters in Vue 2.7.

vue/types/vue.d.ts

export type ExtendedVue<
  Instance extends Vue,
  Data,
  Methods,
  Computed,
  Props,
  SetupBindings
> = VueConstructor<
  CombinedVueInstance<Instance, Data, Methods, Computed, Props, SetupBindings> &
    Vue
>

SetupBindings in vue.d.ts should be optional.

wadizaatour wrote this answer on 2022-08-03

I would like to create a pull request for this issue! can someone help me ?

jf-paradis wrote this answer on 2022-08-05

The change also breaks @vue/test-utils 1.x as both ExtendedVue and CombinedVueInstance are failing.

node_modules/@vue/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>
                                                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@vue/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>
                                                                                                                                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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>
                                                                                                                                                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@vue/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>
                                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@vue/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>
More Details About Repo
Owner Name vuejs
Repo Name vue
Full Name vuejs/vue
Language TypeScript
Created Date 2013-07-29
Updated Date 2022-10-03
Star Count 199758
Watcher Count 6095
Fork Count 32874
Issue Count 590

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date