]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: Revert "fix(types/ref): correct type inference for nested refs (#11536)"
authorEvan You <evan@vuejs.org>
Wed, 7 Aug 2024 10:11:39 +0000 (18:11 +0800)
committerEvan You <evan@vuejs.org>
Wed, 7 Aug 2024 10:11:39 +0000 (18:11 +0800)
This reverts commit 536f62332c455ba82ef2979ba634b831f91928ba.

packages/dts-test/ref.test-d.ts
packages/reactivity/src/ref.ts

index 3161d9d8b55714bc372aa79494589c2e66e56c65..46d39214b930758449c9c310073d65debea0e937 100644 (file)
@@ -180,11 +180,6 @@ describe('allow getter and setter types to be unrelated', <T>() => {
   const d = {} as T
   const e = ref(d)
   e.value = d
-
-  const f = ref(ref(0))
-  expectType<number>(f.value)
-  // @ts-expect-error
-  f.value = ref(1)
 })
 
 // shallowRef
index 3128a8413c0ea024aeaa5349ff55156e7b5637c4..6e22d1bcd58ca29a9fd10f3966db6542166a30ca 100644 (file)
@@ -109,9 +109,7 @@ export function isRef(r: any): r is Ref {
  * @param value - The object to wrap in the ref.
  * @see {@link https://vuejs.org/api/reactivity-core.html#ref}
  */
-export function ref<T>(
-  value: T,
-): [T] extends [Ref] ? IfAny<T, Ref<T>, T> : Ref<UnwrapRef<T>, UnwrapRef<T> | T>
+export function ref<T>(value: T): Ref<UnwrapRef<T>, UnwrapRef<T> | T>
 export function ref<T = any>(): Ref<T | undefined>
 export function ref(value?: unknown) {
   return createRef(value, false)