refactor(compiler): extract shared ast transform utils
Also improve referenced identifier check using isReferenced from @babel/types
This commit is contained in:
@@ -8,27 +8,29 @@ import {
|
||||
WritableComputedRef
|
||||
} from '@vue/reactivity'
|
||||
|
||||
export function $ref<T>(arg: T | Ref<T>): UnwrapRef<T>
|
||||
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): T {
|
||||
return arg
|
||||
}
|
||||
export function $shallowRef<T>(arg?: T): RefValue<T>
|
||||
export function $shallowRef() {}
|
||||
|
||||
declare const ComputedRefMarker: unique symbol
|
||||
type ComputedValue<T> = T & { [ComputedRefMarker]?: any }
|
||||
type ComputedRefValue<T> = T & { [ComputedRefMarker]?: any }
|
||||
|
||||
declare const WritableComputedRefMarker: unique symbol
|
||||
type WritableComputedValue<T> = T & { [WritableComputedRefMarker]?: any }
|
||||
type WritableComputedRefValue<T> = T & { [WritableComputedRefMarker]?: any }
|
||||
|
||||
export function $computed<T>(
|
||||
getter: () => T,
|
||||
debuggerOptions?: DebuggerOptions
|
||||
): ComputedValue<T>
|
||||
): ComputedRefValue<T>
|
||||
export function $computed<T>(
|
||||
options: WritableComputedOptions<T>,
|
||||
debuggerOptions?: DebuggerOptions
|
||||
): WritableComputedValue<T>
|
||||
): WritableComputedRefValue<T>
|
||||
export function $computed() {}
|
||||
|
||||
export function $fromRefs<T>(source: T): ShallowUnwrapRef<T>
|
||||
@@ -36,9 +38,13 @@ export function $fromRefs() {
|
||||
return null as any
|
||||
}
|
||||
|
||||
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<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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user