diff --git a/packages/reactivity/src/reactive.ts b/packages/reactivity/src/reactive.ts index 1881955cf1c..add0765965c 100644 --- a/packages/reactivity/src/reactive.ts +++ b/packages/reactivity/src/reactive.ts @@ -141,7 +141,7 @@ export function shallowReactive( } type Primitive = string | number | boolean | bigint | symbol | undefined | null -type Builtin = Primitive | Function | Date | Error | RegExp +export type Builtin = Primitive | Function | Date | Error | RegExp export type DeepReadonly = T extends Builtin ? T : T extends Map diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 8a48c8abcaa..701d195351f 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -15,7 +15,7 @@ import { isReadonly, isShallow } from './reactive' -import type { ShallowReactiveMarker } from './reactive' +import type { Builtin, ShallowReactiveMarker } from './reactive' import { CollectionTypes } from './collectionHandlers' import { createDep, Dep } from './dep' @@ -138,10 +138,7 @@ class RefImpl { public dep?: Dep = undefined public readonly __v_isRef = true - constructor( - value: T, - public readonly __v_isShallow: boolean - ) { + constructor(value: T, public readonly __v_isShallow: boolean) { this._rawValue = __v_isShallow ? value : toRaw(value) this._value = __v_isShallow ? value : toReactive(value) } @@ -491,8 +488,7 @@ export type UnwrapRef = T extends ShallowRef : UnwrapRefSimple export type UnwrapRefSimple = T extends - | Function - | Date + | Builtin | CollectionTypes | BaseTypes | Ref