Просмотр исходного кода

fix(types): fix instance type inference for setup() with no return value

fix #12568
Evan You 3 лет назад
Родитель
Сommit
65531f5803
2 измененных файлов с 14 добавлено и 1 удалено
  1. 8 0
      types/test/v3/setup-test.ts
  2. 6 1
      types/vue.d.ts

+ 8 - 0
types/test/v3/setup-test.ts

@@ -93,3 +93,11 @@ defineComponent({
     res?.charAt(1)
   }
 })
+
+// #12568
+const vm = new Vue({
+  setup() {},
+  render: h => h({})
+})
+
+vm.$mount('#app')

+ 6 - 1
types/vue.d.ts

@@ -85,7 +85,12 @@ export type CombinedVueInstance<
   Computed,
   Props,
   SetupBindings
-> = Data & Methods & Computed & Props & Instance & SetupBindings
+> = Data &
+  Methods &
+  Computed &
+  Props &
+  Instance &
+  (SetupBindings extends void ? {} : SetupBindings)
 
 export type ExtendedVue<
   Instance extends Vue,