Skip to content

Commit 421a70d

Browse files
authored
test(types): test computed get/set type inference (#1709)
1 parent 06cad62 commit 421a70d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test-dts/defineComponent.test-d.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,19 @@ describe('type inference w/ options API', () => {
269269
d(): number {
270270
expectType<number>(this.b)
271271
return this.b + 1
272+
},
273+
e: {
274+
get(): number {
275+
expectType<number>(this.b)
276+
expectType<number>(this.d)
277+
278+
return this.b + this.d
279+
},
280+
set(v: number) {
281+
expectType<number>(this.b)
282+
expectType<number>(this.d)
283+
expectType<number>(v)
284+
}
272285
}
273286
},
274287
watch: {
@@ -286,6 +299,8 @@ describe('type inference w/ options API', () => {
286299
expectType<number>(this.c)
287300
// computed
288301
expectType<number>(this.d)
302+
// computed get/set
303+
expectType<number>(this.e)
289304
},
290305
methods: {
291306
doSomething() {
@@ -297,6 +312,8 @@ describe('type inference w/ options API', () => {
297312
expectType<number>(this.c)
298313
// computed
299314
expectType<number>(this.d)
315+
// computed get/set
316+
expectType<number>(this.e)
300317
},
301318
returnSomething() {
302319
return this.a
@@ -311,6 +328,8 @@ describe('type inference w/ options API', () => {
311328
expectType<number>(this.c)
312329
// computed
313330
expectType<number>(this.d)
331+
// computed get/set
332+
expectType<number>(this.e)
314333
// method
315334
expectType<() => number | undefined>(this.returnSomething)
316335
}

0 commit comments

Comments
 (0)