瀏覽代碼

typings: type-checking WatchHandler -- refining

Alexander Sheboltaev 9 年之前
父節點
當前提交
ebe27295df
共有 2 個文件被更改,包括 4 次插入2 次删除
  1. 3 1
      types/test/vue-test.ts
  2. 1 1
      types/vue.d.ts

+ 3 - 1
types/test/vue-test.ts

@@ -1,6 +1,8 @@
 import Vue = require("../index");
 
 class Test extends Vue {
+  a: number;
+
   testProperties() {
     this.$data;
     this.$el;
@@ -37,7 +39,7 @@ class Test extends Vue {
       immediate: true,
       deep: false
     })();
-    this.$watch(() => {}, (val: number) => {});
+    this.$watch(() => this.a, (val: number) => {});
     this.$on("", () => {});
     this.$once("", () => {});
     this.$off("", () => {});

+ 1 - 1
types/vue.d.ts

@@ -55,7 +55,7 @@ export declare class Vue {
     options?: WatchOptions
   ): (() => void);
   $watch<T>(
-    expOrFn: () => T,
+    expOrFn: (this: this) => T,
     callback: WatchHandler<this, T>,
     options?: WatchOptions
   ): (() => void);