test(types): test computed get/set type inference (#1709)
This commit is contained in:
parent
06cad62ee8
commit
421a70de5e
@ -269,6 +269,19 @@ describe('type inference w/ options API', () => {
|
|||||||
d(): number {
|
d(): number {
|
||||||
expectType<number>(this.b)
|
expectType<number>(this.b)
|
||||||
return this.b + 1
|
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: {
|
watch: {
|
||||||
@ -286,6 +299,8 @@ describe('type inference w/ options API', () => {
|
|||||||
expectType<number>(this.c)
|
expectType<number>(this.c)
|
||||||
// computed
|
// computed
|
||||||
expectType<number>(this.d)
|
expectType<number>(this.d)
|
||||||
|
// computed get/set
|
||||||
|
expectType<number>(this.e)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
doSomething() {
|
doSomething() {
|
||||||
@ -297,6 +312,8 @@ describe('type inference w/ options API', () => {
|
|||||||
expectType<number>(this.c)
|
expectType<number>(this.c)
|
||||||
// computed
|
// computed
|
||||||
expectType<number>(this.d)
|
expectType<number>(this.d)
|
||||||
|
// computed get/set
|
||||||
|
expectType<number>(this.e)
|
||||||
},
|
},
|
||||||
returnSomething() {
|
returnSomething() {
|
||||||
return this.a
|
return this.a
|
||||||
@ -311,6 +328,8 @@ describe('type inference w/ options API', () => {
|
|||||||
expectType<number>(this.c)
|
expectType<number>(this.c)
|
||||||
// computed
|
// computed
|
||||||
expectType<number>(this.d)
|
expectType<number>(this.d)
|
||||||
|
// computed get/set
|
||||||
|
expectType<number>(this.e)
|
||||||
// method
|
// method
|
||||||
expectType<() => number | undefined>(this.returnSomething)
|
expectType<() => number | undefined>(this.returnSomething)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user