Skip to content

Commit 42942e9

Browse files
fix(types): fix shallowRef type error
1 parent 305e4ae commit 42942e9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: src/v3/reactivity/ref.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ declare const ShallowRefMarker: unique symbol
5151

5252
export type ShallowRef<T = any> = Ref<T> & { [ShallowRefMarker]?: true }
5353

54-
export function shallowRef<T>(value: T | Ref<T>): Ref<T> | ShallowRef<T>
55-
export function shallowRef<T extends Ref>(value: T): T
56-
export function shallowRef<T>(value: T): ShallowRef<T>
54+
export function shallowRef<T>(
55+
value: T
56+
): 1 extends (T extends Ref ? 1 : 0)
57+
? T extends Ref
58+
? IfAny<T, ShallowRef<T>, T>
59+
: ShallowRef<T>
60+
: ShallowRef<T>
5761
export function shallowRef<T = any>(): ShallowRef<T | undefined>
5862
export function shallowRef(value?: unknown) {
5963
return createRef(value, true)

0 commit comments

Comments
 (0)