Skip to content

Commit 2e3297e

Browse files
committed
fix: use inner Exclude type function to resolve it
microsoft/TypeScript#56813
1 parent 7f1f421 commit 2e3297e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/base.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ type LastInUnion<U> = U2I<
1717
? L
1818
: never
1919

20+
type U2T_Exclude<T,U> = T extends U ? (<A>() => (A extends T ? 1 : 2)) extends (<A>() => (A extends U ? 1 : 2)) ? never : T : T
2021
/**
2122
* U2T<1 | 2> = [1, 2].
2223
*/
2324
export type U2T<U, Last = LastInUnion<U>> = [U] extends [never]
2425
? []
25-
: [...U2T<Exclude<U, Last>>, Last]
26+
: [...U2T<U2T_Exclude<U, Last>>, Last]
2627

2728
type IsUnion<T, U = T> = T extends U ? ([U] extends [T] ? false : true) : false
2829

0 commit comments

Comments
 (0)