소스 검색

fix(types): infer the first generic type of `Ref` correctly (#12094)

山吹色御守 1 년 전
부모
커밋
c97bb84d0b
2개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 1
      packages/reactivity/src/reactive.ts
  2. 3 3
      packages/reactivity/src/ref.ts

+ 1 - 1
packages/reactivity/src/reactive.ts

@@ -167,7 +167,7 @@ export type DeepReadonly<T> = T extends Builtin
               ? WeakSet<DeepReadonly<U>>
               : T extends Promise<infer U>
                 ? Promise<DeepReadonly<U>>
-                : T extends Ref<infer U>
+                : T extends Ref<infer U, unknown>
                   ? Readonly<Ref<DeepReadonly<U>>>
                   : T extends {}
                     ? { readonly [K in keyof T]: DeepReadonly<T[K]> }

+ 3 - 3
packages/reactivity/src/ref.ts

@@ -489,12 +489,12 @@ export type ShallowUnwrapRef<T> = {
   [K in keyof T]: DistributeRef<T[K]>
 }
 
-type DistributeRef<T> = T extends Ref<infer V> ? V : T
+type DistributeRef<T> = T extends Ref<infer V, unknown> ? V : T
 
 export type UnwrapRef<T> =
-  T extends ShallowRef<infer V, infer _>
+  T extends ShallowRef<infer V, unknown>
     ? V
-    : T extends Ref<infer V, infer _>
+    : T extends Ref<infer V, unknown>
       ? UnwrapRefSimple<V>
       : UnwrapRefSimple<T>