Skip to content

Commit f8994da

Browse files
authored
types: improve readability of built-in type (#9129)
1 parent 70f2f28 commit f8994da

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

packages/reactivity/src/reactive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export function shallowReactive<T extends object>(
135135
}
136136

137137
type Primitive = string | number | boolean | bigint | symbol | undefined | null
138-
type Builtin = Primitive | Function | Date | Error | RegExp
138+
export type Builtin = Primitive | Function | Date | Error | RegExp
139139
export type DeepReadonly<T> = T extends Builtin
140140
? T
141141
: T extends Map<infer K, infer V>

packages/reactivity/src/ref.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
toRaw,
2222
toReactive,
2323
} from './reactive'
24-
import type { ShallowReactiveMarker } from './reactive'
24+
import type { Builtin, ShallowReactiveMarker } from './reactive'
2525
import { type Dep, createDep } from './dep'
2626
import { ComputedRefImpl } from './computed'
2727
import { getDepFromReactive } from './reactiveEffect'
@@ -475,11 +475,6 @@ function propertyToRef(
475475
: (new ObjectRefImpl(source, key, defaultValue) as any)
476476
}
477477

478-
// corner case when use narrows type
479-
// Ex. type RelativePath = string & { __brand: unknown }
480-
// RelativePath extends object -> true
481-
type BaseTypes = string | number | boolean
482-
483478
/**
484479
* This is a special exported interface for other packages to declare
485480
* additional types that should bail out for ref unwrapping. For example
@@ -509,8 +504,7 @@ export type UnwrapRef<T> =
509504
: UnwrapRefSimple<T>
510505

511506
export type UnwrapRefSimple<T> = T extends
512-
| Function
513-
| BaseTypes
507+
| Builtin
514508
| Ref
515509
| RefUnwrapBailTypes[keyof RefUnwrapBailTypes]
516510
| { [RawSymbol]?: true }

packages/runtime-core/src/compat/instance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ export interface LegacyPublicProperties {
4646
$set<T extends Record<keyof any, any>, K extends keyof T>(
4747
target: T,
4848
key: K,
49-
value: T[K]
49+
value: T[K],
5050
): void
5151
$delete<T extends Record<keyof any, any>, K extends keyof T>(
5252
target: T,
53-
key: K
53+
key: K,
5454
): void
5555
$mount(el?: string | Element): this
5656
$destroy(): void

0 commit comments

Comments
 (0)