types: improve ref sugar $computed typing

This commit is contained in:
Evan You
2021-08-20 00:07:16 -04:00
parent 872b3f7ec5
commit 4adc5042f9
2 changed files with 44 additions and 5 deletions

View File

@@ -1,4 +1,12 @@
import { Ref, UnwrapRef, ShallowUnwrapRef, ComputedRef } from '@vue/reactivity'
import {
Ref,
UnwrapRef,
ShallowUnwrapRef,
ComputedRef,
WritableComputedOptions,
DebuggerOptions,
WritableComputedRef
} from '@vue/reactivity'
export function $ref<T>(arg: T | Ref<T>): UnwrapRef<T>
export function $ref() {}
@@ -8,9 +16,19 @@ export function $shallowRef<T>(arg: T): T {
}
declare const ComputedRefMarker: unique symbol
type ComputedRefValue<T> = T & { [ComputedRefMarker]?: any }
type ComputedValue<T> = T & { [ComputedRefMarker]?: any }
export function $computed<T>(getter: () => T): ComputedRefValue<T>
declare const WritableComputedRefMarker: unique symbol
type WritableComputedValue<T> = T & { [WritableComputedRefMarker]?: any }
export function $computed<T>(
getter: () => T,
debuggerOptions?: DebuggerOptions
): ComputedValue<T>
export function $computed<T>(
options: WritableComputedOptions<T>,
debuggerOptions?: DebuggerOptions
): WritableComputedValue<T>
export function $computed() {}
export function $fromRefs<T>(source: T): ShallowUnwrapRef<T>
@@ -18,7 +36,8 @@ export function $fromRefs() {
return null as any
}
export function $raw<T>(value: ComputedRefValue<T>): ComputedRef<T>
export function $raw<T>(value: ComputedValue<T>): ComputedRef<T>
export function $raw<T>(value: WritableComputedValue<T>): WritableComputedRef<T>
export function $raw<T>(value: T): Ref<T>
export function $raw() {
return null as any