-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEachAsSingle.ts
45 lines (43 loc) · 980 Bytes
/
EachAsSingle.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* id: 12
* name: EachAsSingle
* difficulty: 3
* description: Given a union, make a union of each member in the original wrapped in an object.
* extra: Do the reverse of this challenge.
* tags: fundamentals, unions
* related: UnionToIntersection
*
* @format
*/
import { Assert, Equals, Never } from "./common";
import { EachAsSingle } from "./solutions/EachAsSingle";
type T01 = Assert<
Equals<
EachAsSingle<"one" | "two" | "three">,
| {
wrapped: "one";
}
| {
wrapped: "two";
}
| {
wrapped: "three";
}
>
>;
type T02 = Assert<Equals<EachAsSingle<"">, { wrapped: "" }>>;
type T03 = Assert<
Equals<
EachAsSingle<1 | 2 | 3>,
| {
wrapped: 1;
}
| {
wrapped: 2;
}
| {
wrapped: 3;
}
>
>;
type T04 = Assert<Equals<Never<EachAsSingle<never>>, true>>;