Skip to content

Commit d3d5ad2

Browse files
authored
fix(types): remove explicit return type annotation requirement for this inference in computed options (#4221)
1 parent 2f1f616 commit d3d5ad2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/reactivity/src/computed.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface WritableComputedRef<T> extends Ref<T> {
1212
readonly effect: ReactiveEffect<T>
1313
}
1414

15-
export type ComputedGetter<T> = (ctx?: any) => T
15+
export type ComputedGetter<T> = (...args: any[]) => T
1616
export type ComputedSetter<T> = (v: T) => void
1717

1818
export interface WritableComputedOptions<T> {

test-dts/defineComponent.test-d.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,12 @@ describe('type inference w/ options API', () => {
396396
}
397397
},
398398
computed: {
399-
d(): number {
399+
d() {
400400
expectType<number>(this.b)
401401
return this.b + 1
402402
},
403403
e: {
404-
get(): number {
404+
get() {
405405
expectType<number>(this.b)
406406
expectType<number>(this.d)
407407

@@ -514,10 +514,10 @@ describe('with mixins', () => {
514514
expectType<string>(props.aP1)
515515
},
516516
computed: {
517-
dC1(): number {
517+
dC1() {
518518
return this.d + this.a
519519
},
520-
dC2(): string {
520+
dC2() {
521521
return this.aP1 + 'dC2'
522522
}
523523
}
@@ -926,7 +926,7 @@ describe('emits', () => {
926926
},
927927
mounted() {
928928
// #3599
929-
this.$nextTick(function() {
929+
this.$nextTick(function () {
930930
// this should be bound to this instance
931931

932932
this.$emit('click', 1)

0 commit comments

Comments
 (0)