Skip to content

Commit d76eed6

Browse files
committed
add day 14
1 parent 9a30cef commit d76eed6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

2024/14/index.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* eslint-disable @typescript-eslint/require-await */
2+
import type { Expect, Equal } from "type-testing";
3+
4+
type PerfReview<T> =
5+
T extends AsyncGenerator<infer Y, unknown, never> ? Y : never;
6+
7+
// ------------------- Test section ---------------------
8+
9+
async function* numberAsyncGenerator() {
10+
yield 1;
11+
yield 2;
12+
yield 3;
13+
}
14+
type t0_type = typeof numberAsyncGenerator;
15+
type t0_actual = PerfReview<ReturnType<t0_type>>;
16+
type t0_expected = 1 | 2 | 3;
17+
type t0 = Expect<Equal<t0_actual, t0_expected>>;
18+
19+
async function* stringAsyncGenerator() {
20+
yield "1%";
21+
yield "2%";
22+
}
23+
type t1_type = typeof stringAsyncGenerator;
24+
type t1_actual = PerfReview<ReturnType<t1_type>>;
25+
type t1_expected = "1%" | "2%";
26+
type t1 = Expect<Equal<t1_actual, t1_expected>>;

0 commit comments

Comments
 (0)