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

fix(types): fix error with options watch (#12779)

fix #12780
fukang wang 3 лет назад
Родитель
Сommit
bc5b92adde
2 измененных файлов с 9 добавлено и 2 удалено
  1. 1 1
      types/options.d.ts
  2. 8 1
      types/test/options-test.ts

+ 1 - 1
types/options.d.ts

@@ -181,7 +181,7 @@ export interface ComponentOptions<
   propsData?: object
   computed?: Accessors<Computed>
   methods?: Methods
-  watch?: Record<string, WatchOptionsWithHandler<any> | WatchHandler<any>>
+  watch?: Record<string, WatchOptionsWithHandler<any> | WatchHandler<any> | Array<WatchOptionsWithHandler<any> | WatchHandler<any>>>
 
   setup?: (
     this: void,

+ 8 - 1
types/test/options-test.ts

@@ -172,7 +172,14 @@ Vue.component('component', {
     d: {
       handler: 'someMethod',
       immediate: true
-    }
+    },
+    e: [
+      'handle1',
+      function handle2 (val, oldVal) {},
+      {
+        handler: function handle3 (val, oldVal) {},
+      }
+    ],
   },
   el: '#app',
   template: '<div>{{ message }}</div>',