Skip to content
Closed
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
8 changes: 7 additions & 1 deletion packages/reactivity/src/computed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ export interface WritableComputedRef<T> extends Ref<T> {
readonly effect: ReactiveEffect<T>
}

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

export interface WritableComputedOptions<T> {
get: ComputedGetter<T>
set: ComputedSetter<T>
}

export interface WritableComputedOptionsWithInstance<T> {
get: ComputedGetterWithInstance<T>
set: ComputedSetter<T>
}

export class ComputedRefImpl<T> {
public dep?: Dep = undefined

Expand Down
2 changes: 2 additions & 0 deletions packages/reactivity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export {
ComputedRef,
WritableComputedRef,
WritableComputedOptions,
WritableComputedOptionsWithInstance,
ComputedGetter,
ComputedGetterWithInstance,
ComputedSetter
} from './computed'
export { deferredComputed } from './deferredComputed'
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime-core/src/componentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ import {
} from './apiLifecycle'
import {
reactive,
ComputedGetter,
WritableComputedOptions
ComputedGetterWithInstance,
WritableComputedOptionsWithInstance
} from '@vue/reactivity'
import {
ComponentObjectPropsOptions,
Expand Down Expand Up @@ -360,7 +360,7 @@ export type ComponentOptionsMixin = ComponentOptionsBase<

export type ComputedOptions = Record<
string,
ComputedGetter<any> | WritableComputedOptions<any>
ComputedGetterWithInstance<any> | WritableComputedOptionsWithInstance<any>
>

export interface MethodOptions {
Expand Down