]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(types): test computed get/set type inference (#1709)
authorCarlos Rodrigues <david-181@hotmail.com>
Tue, 28 Jul 2020 19:40:23 +0000 (20:40 +0100)
committerGitHub <noreply@github.com>
Tue, 28 Jul 2020 19:40:23 +0000 (15:40 -0400)
test-dts/defineComponent.test-d.tsx

index 29194ca391299b5093ab9b82fb44bda23ba1eb4f..dcbad6a0fad6ded703540da62a1ad011137e437d 100644 (file)
@@ -269,6 +269,19 @@ describe('type inference w/ options API', () => {
       d(): number {
         expectType<number>(this.b)
         return this.b + 1
+      },
+      e: {
+        get(): number {
+          expectType<number>(this.b)
+          expectType<number>(this.d)
+
+          return this.b + this.d
+        },
+        set(v: number) {
+          expectType<number>(this.b)
+          expectType<number>(this.d)
+          expectType<number>(v)
+        }
       }
     },
     watch: {
@@ -286,6 +299,8 @@ describe('type inference w/ options API', () => {
       expectType<number>(this.c)
       // computed
       expectType<number>(this.d)
+      // computed get/set
+      expectType<number>(this.e)
     },
     methods: {
       doSomething() {
@@ -297,6 +312,8 @@ describe('type inference w/ options API', () => {
         expectType<number>(this.c)
         // computed
         expectType<number>(this.d)
+        // computed get/set
+        expectType<number>(this.e)
       },
       returnSomething() {
         return this.a
@@ -311,6 +328,8 @@ describe('type inference w/ options API', () => {
       expectType<number>(this.c)
       // computed
       expectType<number>(this.d)
+      // computed get/set
+      expectType<number>(this.e)
       // method
       expectType<() => number | undefined>(this.returnSomething)
     }