SetupBindings in vue.d.ts should be optional

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

Vue version

2.7.8

Link to minimal reproduction

https://stackblitz.com/edit/node-bwjvef?file=src/app.ts

Steps to reproduce

run npx tsc in terminal.

You will get following error:

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
>

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04 LTS 22.04 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz
    Memory: 10.14 GB / 15.63 GB
    Container: Yes
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - /usr/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 8.11.0 - /usr/bin/npm
  npmPackages:
    vue: ^2.7.8 => 2.7.8

Any additional comments?

SetupBindings in vue.d.ts should be optional.

hubvue wrote this answer on 2022-07-29

This is the 3.x version of the repository, I assume you are raising the issue in the 2.x version of the repository. vue2.x

vue-bot wrote this answer on 2022-07-29

Hello, thank you for taking time filling this issue!

However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!).

I hope to see your helper-created issue very soon!

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 199770
Watcher Count 6094
Fork Count 32877
Issue Count 590

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date