Skip to content

Commit 18b3c56

Browse files
author
RicardoErii
committed
test(reactivity): support distribution of union types
1 parent a8d0b1b commit 18b3c56

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/reactivity/src/ref.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,15 @@ type BaseTypes = string | number | boolean
476476
*/
477477
export interface RefUnwrapBailTypes {}
478478

479+
type DistrubuteRef<T> = T extends Ref<infer V>
480+
? unknown extends V
481+
? never
482+
: V
483+
: T
479484
export type ShallowUnwrapRef<T> = {
480485
[K in keyof T]: T[K] extends Ref<infer V>
481486
? V // if `V` is `unknown` that means it does not extend `Ref` and is undefined
482-
: T[K] extends Ref<infer V> | undefined
483-
? unknown extends V
484-
? undefined
485-
: V | undefined
486-
: T[K]
487+
: DistrubuteRef<T[K]>
487488
}
488489

489490
export type UnwrapRef<T> = T extends ShallowRef<infer V>

0 commit comments

Comments
 (0)