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

SetupBindings in vue.d.ts should be optional #12717

Closed
mingc00 opened this issue Jul 29, 2022 · 2 comments
Closed

SetupBindings in vue.d.ts should be optional #12717

mingc00 opened this issue Jul 29, 2022 · 2 comments

Comments

@mingc00
Copy link

mingc00 commented Jul 29, 2022

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
Copy link

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

@jfparadis-appomni
Copy link
Contributor

jfparadis-appomni commented Aug 5, 2022

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>

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

No branches or pull requests

3 participants