-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday07.ts
41 lines (36 loc) · 1015 Bytes
/
day07.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
import { Equal, Expect } from "../../testing-types";
/* Solution */
type AppendGood<T> = {
[K in keyof T & string as `good_${K}`]: T[K];
};
/* Tests */
type WellBehavedList = {
tom: { address: "1 candy cane lane" };
timmy: { address: "43 chocolate dr" };
trash: { address: "637 starlight way" };
candace: { address: "12 aurora" };
};
type test_wellBehaved_actual = AppendGood<WellBehavedList>;
// ^?
type test_wellBehaved_expected = {
good_tom: { address: "1 candy cane lane" };
good_timmy: { address: "43 chocolate dr" };
good_trash: { address: "637 starlight way" };
good_candace: { address: "12 aurora" };
};
type test_wellBehaved = Expect<
Equal<test_wellBehaved_expected, test_wellBehaved_actual>
>;
type Unrelated = {
dont: "cheat";
play: "fair";
};
type test_Unrelated_actual = AppendGood<Unrelated>;
// ^?
type test_Unrelated_expected = {
good_dont: "cheat";
good_play: "fair";
};
type test_Unrelated = Expect<
Equal<test_Unrelated_expected, test_Unrelated_actual>
>;