Skip to content

Commit

Permalink
fix(types): make toRefs return correct type(fix vuejs#5188) (vuejs#…
Browse files Browse the repository at this point in the history
  • Loading branch information
macheteHot committed Dec 31, 2021
1 parent 7007ffb commit 7942a19
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/reactivity/src/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { isProxy, toRaw, isReactive, toReactive } from './reactive'
import type { ShallowReactiveMarker } from './reactive'
import { CollectionTypes } from './collectionHandlers'
import { createDep, Dep } from './dep'
import { IfAny } from 'packages/runtime-core/src/helpers/typeUtils'

declare const RefSymbol: unique symbol

Expand Down Expand Up @@ -222,7 +223,8 @@ class ObjectRefImpl<T extends object, K extends keyof T> {
}
}

export type ToRef<T> = [T] extends [Ref] ? T : Ref<T>
export type ToRef<T> = IfAny<T,Ref<T>,[T] extends [Ref] ? T : Ref<T>>


export function toRef<T extends object, K extends keyof T>(
object: T,
Expand Down

0 comments on commit 7942a19

Please sign in to comment.