types: improve writable computed types (#192)
This commit is contained in:
parent
f71d252ffe
commit
1139368dc2
@ -22,11 +22,11 @@ export {
|
|||||||
} from '@vue/reactivity'
|
} from '@vue/reactivity'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Ref,
|
|
||||||
computed as _computed,
|
computed as _computed,
|
||||||
ComputedRef,
|
ComputedRef,
|
||||||
WritableComputedOptions,
|
WritableComputedOptions,
|
||||||
ReactiveEffect
|
ReactiveEffect,
|
||||||
|
WritableComputedRef
|
||||||
} from '@vue/reactivity'
|
} from '@vue/reactivity'
|
||||||
|
|
||||||
import { currentInstance } from './component'
|
import { currentInstance } from './component'
|
||||||
@ -40,9 +40,13 @@ export function recordEffect(effect: ReactiveEffect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function computed<T>(getter: () => T): ComputedRef<T>
|
export function computed<T>(getter: () => T): ComputedRef<T>
|
||||||
export function computed<T>(options: WritableComputedOptions<T>): Ref<T>
|
export function computed<T>(
|
||||||
export function computed<T>(getterOrOptions: any) {
|
options: WritableComputedOptions<T>
|
||||||
const c = _computed(getterOrOptions)
|
): WritableComputedRef<T>
|
||||||
|
export function computed<T>(
|
||||||
|
getterOrOptions: (() => T) | WritableComputedOptions<T>
|
||||||
|
) {
|
||||||
|
const c = _computed(getterOrOptions as any)
|
||||||
recordEffect(c.effect)
|
recordEffect(c.effect)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user