Skip to content

Commit

Permalink
wip(types): toRef
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Aug 17, 2024
1 parent 77e379e commit 4c5ee9b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/reactivity/src/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,17 @@ export function toRef<T extends object, K extends keyof T>(
key: K,
defaultValue: T[K],
): ToRef<Exclude<T[K], undefined>>
// fixed by xxxxxx toRef<number>({num:1},'num')
export function toRef<T>(
value: object,
key: string,
): T extends () => infer R
? Readonly<Ref<R>>
: T extends Ref
? T
: Ref<UnwrapRef<T>>
// fixed by xxxxxx toRef<number>((): number => 1))
export function toRef<T>(value: () => T): Readonly<Ref<T>>
export function toRef(
source: Record<string, any> | MaybeRef,
key?: string,
Expand Down

0 comments on commit 4c5ee9b

Please sign in to comment.