Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

‎src/v3/reactivity/ref.ts‎

Lines changed: 7 additions & 3 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /