Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): fix this type broken in computed options #4221

Merged
merged 2 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/reactivity/src/computed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface WritableComputedRef<T> extends Ref<T> {
readonly effect: ReactiveEffect<T>
}

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

export interface WritableComputedOptions<T> {
Expand Down
10 changes: 5 additions & 5 deletions test-dts/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,12 @@ describe('type inference w/ options API', () => {
}
},
computed: {
d(): number {
d() {
expectType<number>(this.b)
return this.b + 1
},
e: {
get(): number {
get() {
expectType<number>(this.b)
expectType<number>(this.d)

Expand Down Expand Up @@ -514,10 +514,10 @@ describe('with mixins', () => {
expectType<string>(props.aP1)
},
computed: {
dC1(): number {
dC1() {
return this.d + this.a
},
dC2(): string {
dC2() {
return this.aP1 + 'dC2'
}
}
Expand Down Expand Up @@ -926,7 +926,7 @@ describe('emits', () => {
},
mounted() {
// #3599
this.$nextTick(function() {
this.$nextTick(function () {
// this should be bound to this instance

this.$emit('click', 1)
Expand Down