-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday2.ts
38 lines (35 loc) · 818 Bytes
/
day2.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
/*Solution*/
type CookieSurveyInput<T> = keyof T;
/*Tests*/
import { Expect, Equal } from "type-testing";
const cookieInventory = {
chocolate: 1,
sugar: 20,
gingerBread: 10,
peanutButter: 30,
snickeDoodle: 73,
}
type test_cookies_actual = CookieSurveyInput<typeof cookieInventory>;
// ^?
type test_cookies_expected = "chocolate" | "sugar" | "gingerBread" | "peanutButter" | "snickeDoodle";
type test_cookies = Expect<
Equal<
test_cookies_actual,
test_cookies_expected
>
>;
const unrelated = {
hi: 1,
hi2: 1,
hi3: 1,
hi4: 1,
hi5: 1,
hi6: 1,
hi7: 1,
}
type test_unrelated_actual = CookieSurveyInput<typeof unrelated>;
// ^?
type test_unrealted_expected = "hi" | "hi2" | "hi3" | "hi4" | "hi5" | "hi6" | "hi7"
type test_unrelated = Expect<
Equal<test_unrelated_actual, test_unrealted_expected>
>;