feat(experimental): expose ref macro types using separate d.ts file

This commit is contained in:
Evan You
2021-08-23 20:35:12 -04:00
parent afd49b3e88
commit b40845153c
5 changed files with 97 additions and 94 deletions

View File

@@ -1,50 +0,0 @@
import {
Ref,
UnwrapRef,
ShallowUnwrapRef,
ComputedRef,
WritableComputedOptions,
DebuggerOptions,
WritableComputedRef
} from '@vue/reactivity'
declare const RefMarker: unique symbol
type RefValue<T> = T & { [RefMarker]?: any }
export function $ref<T>(arg?: T | Ref<T>): RefValue<UnwrapRef<T>>
export function $ref() {}
export function $shallowRef<T>(arg?: T): RefValue<T>
export function $shallowRef() {}
declare const ComputedRefMarker: unique symbol
type ComputedRefValue<T> = T & { [ComputedRefMarker]?: any }
declare const WritableComputedRefMarker: unique symbol
type WritableComputedRefValue<T> = T & { [WritableComputedRefMarker]?: any }
export function $computed<T>(
getter: () => T,
debuggerOptions?: DebuggerOptions
): ComputedRefValue<T>
export function $computed<T>(
options: WritableComputedOptions<T>,
debuggerOptions?: DebuggerOptions
): WritableComputedRefValue<T>
export function $computed() {}
export function $fromRefs<T>(source: T): ShallowUnwrapRef<T>
export function $fromRefs() {
return null as any
}
export function $raw<T extends ComputedRefValue<any>>(
value: T
): T extends ComputedRefValue<infer V> ? ComputedRef<V> : never
export function $raw<T>(
value: WritableComputedRefValue<T>
): WritableComputedRef<T>
export function $raw<T>(value: RefValue<T>): Ref<T>
export function $raw() {
return null as any
}

View File

@@ -149,6 +149,7 @@ declare module '@vue/reactivity' {
export {
ReactiveEffectOptions,
DebuggerEvent,
DebuggerOptions,
TrackOpTypes,
TriggerOpTypes,
Ref,
@@ -351,13 +352,3 @@ const _compatUtils = {
export const compatUtils = (
__COMPAT__ ? _compatUtils : null
) as typeof _compatUtils
// Ref sugar macros ------------------------------------------------------------
// for dts generation only
export {
$ref,
$shallowRef,
$computed,
$raw,
$fromRefs
} from './helpers/refSugar'