We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 085d1d5 commit 89c0f06Copy full SHA for 89c0f06
test-d/union-member.ts
@@ -12,8 +12,9 @@ expectType<never>({} as UnionMember<never>);
12
expectType<unknown>({} as UnionMember<unknown>);
13
expectType<any>({} as UnionMember<any>);
14
15
+// Ensure exactly one member is selected at a time, while covering all members in the union.
16
type UnionToTupleWithExclude<T, L = UnionMember<T>> =
17
IsNever<T> extends false
- ? [...UnionToTupleWithExclude<Exclude<T, L>>, L]
18
- : [];
19
-expectType<1 | 2 | 3>({} as UnionToTupleWithExclude<1 | 2 | 3>[number]);
+ ? UnionToTupleWithExclude<Exclude<T, L>> | [L]
+ : never;
20
+expectType<[1] | [2] | [3]>({} as UnionToTupleWithExclude<1 | 2 | 3>);
0 commit comments