Skip to content

Commit

Permalink
types: use Primitive to instead of BaseType
Browse files Browse the repository at this point in the history
  • Loading branch information
Mini-ghost committed Dec 11, 2023
1 parent 9a0676c commit 57dc127
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions packages/reactivity/src/reactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,15 @@ export function shallowReactive<T extends object>(
)
}

type Primitive = string | number | boolean | bigint | symbol | undefined | null
export type Builtin = Primitive | Function | Date | Error | RegExp
export type Primitive =
| string
| number
| boolean
| bigint
| symbol
| undefined
| null
export type Builtin = Function | Date | Error | RegExp
export type DeepReadonly<T> = T extends Builtin
? T
: T extends Map<infer K, infer V>
Expand Down
3 changes: 2 additions & 1 deletion packages/reactivity/src/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
isReadonly,
isShallow
} from './reactive'
import type { Builtin, ShallowReactiveMarker } from './reactive'
import type { Builtin, Primitive, ShallowReactiveMarker } from './reactive'
import { createDep, Dep } from './dep'

declare const RefSymbol: unique symbol
Expand Down Expand Up @@ -484,6 +484,7 @@ export type UnwrapRef<T> = T extends ShallowRef<infer V>
: UnwrapRefSimple<T>

export type UnwrapRefSimple<T> = T extends
| Primitive
| Builtin
| Ref
| RefUnwrapBailTypes[keyof RefUnwrapBailTypes]
Expand Down

0 comments on commit 57dc127

Please sign in to comment.