feat(sfc): support $shallowRef ref sugar
This commit is contained in:
@@ -3,6 +3,10 @@ import { Ref, UnwrapRef, ShallowUnwrapRef, ComputedRef } from '@vue/reactivity'
|
||||
export function $ref<T>(arg: T | Ref<T>): UnwrapRef<T>
|
||||
export function $ref() {}
|
||||
|
||||
export function $shallowRef<T>(arg: T): T {
|
||||
return arg
|
||||
}
|
||||
|
||||
declare const ComputedRefMarker: unique symbol
|
||||
type ComputedRefValue<T> = T & { [ComputedRefMarker]?: any }
|
||||
|
||||
|
||||
@@ -354,4 +354,10 @@ export const compatUtils = (
|
||||
|
||||
// Ref sugar macros ------------------------------------------------------------
|
||||
// for dts generation only
|
||||
export { $ref, $computed, $raw, $fromRefs } from './helpers/refSugar'
|
||||
export {
|
||||
$ref,
|
||||
$shallowRef,
|
||||
$computed,
|
||||
$raw,
|
||||
$fromRefs
|
||||
} from './helpers/refSugar'
|
||||
|
||||
@@ -6,6 +6,7 @@ type _defineExpose = typeof defineExpose
|
||||
type _withDefaults = typeof withDefaults
|
||||
|
||||
type _ref = typeof $ref
|
||||
type _shallowRef = typeof $shallowRef
|
||||
type _computed = typeof $computed
|
||||
type _fromRefs = typeof $fromRefs
|
||||
type _raw = typeof $raw
|
||||
@@ -17,6 +18,7 @@ declare global {
|
||||
const withDefaults: _withDefaults
|
||||
|
||||
const $ref: _ref
|
||||
const $shallowRef: _shallowRef
|
||||
const $computed: _computed
|
||||
const $fromRefs: _fromRefs
|
||||
const $raw: _raw
|
||||
|
||||
Reference in New Issue
Block a user