Skip to content

Commit

Permalink
types: use Builtin instead of Function and Date
Browse files Browse the repository at this point in the history
  • Loading branch information
Mini-ghost committed Sep 5, 2023
1 parent 94a81b6 commit 0462f86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/reactivity/src/reactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function shallowReactive<T extends object>(
}

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> = T extends Builtin
? T
: T extends Map<infer K, infer V>
Expand Down
10 changes: 3 additions & 7 deletions packages/reactivity/src/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -138,10 +138,7 @@ class RefImpl<T> {
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)
}
Expand Down Expand Up @@ -491,8 +488,7 @@ export type UnwrapRef<T> = T extends ShallowRef<infer V>
: UnwrapRefSimple<T>

export type UnwrapRefSimple<T> = T extends
| Function
| Date
| Builtin
| CollectionTypes
| BaseTypes
| Ref
Expand Down

0 comments on commit 0462f86

Please sign in to comment.