parent
6cfd72e760
commit
5ac703055f
@ -1,6 +1,6 @@
|
|||||||
import { isTracking, trackEffects, triggerEffects } from './effect'
|
import { isTracking, trackEffects, triggerEffects } from './effect'
|
||||||
import { TrackOpTypes, TriggerOpTypes } from './operations'
|
import { TrackOpTypes, TriggerOpTypes } from './operations'
|
||||||
import { isArray, hasChanged } from '@vue/shared'
|
import { isArray, hasChanged, IfAny } from '@vue/shared'
|
||||||
import { isProxy, toRaw, isReactive, toReactive } from './reactive'
|
import { isProxy, toRaw, isReactive, toReactive } from './reactive'
|
||||||
import type { ShallowReactiveMarker } from './reactive'
|
import type { ShallowReactiveMarker } from './reactive'
|
||||||
import { CollectionTypes } from './collectionHandlers'
|
import { CollectionTypes } from './collectionHandlers'
|
||||||
@ -222,7 +222,7 @@ 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>(
|
export function toRef<T extends object, K extends keyof T>(
|
||||||
object: T,
|
object: T,
|
||||||
|
@ -222,6 +222,11 @@ expectType<Ref<string>>(p2.obj.k)
|
|||||||
|
|
||||||
expectType<Ref<number>>(toRefResult.value.b)
|
expectType<Ref<number>>(toRefResult.value.b)
|
||||||
expectType<Ref<number>>(toRefsResult.a.value.b)
|
expectType<Ref<number>>(toRefsResult.a.value.b)
|
||||||
|
|
||||||
|
// #5188
|
||||||
|
const props = { foo: 1 } as { foo: any }
|
||||||
|
const { foo } = toRefs(props)
|
||||||
|
expectType<Ref<any>>(foo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// toRef default value
|
// toRef default value
|
||||||
|
Loading…
Reference in New Issue
Block a user