Skip to content

Commit 9cb14fe

Browse files
committed
Add tests
1 parent 5895057 commit 9cb14fe

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// @strict: true
2+
// @declaration: true
3+
4+
// Repro from #17456
5+
6+
type StringContains<S extends string, L extends string> = (
7+
{ [K in S]: 'true' } &
8+
{ [key: string]: 'false' }
9+
)[L]
10+
11+
type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>
12+
13+
type First<T> = ObjectHasKey<T, '0'>; // Should be deferred
14+
15+
type T1 = ObjectHasKey<{ a: string }, 'a'>; // 'true'
16+
type T2 = ObjectHasKey<{ a: string }, 'b'>; // 'false'
17+
18+
// Verify that mapped type isn't eagerly resolved in type-to-string operation
19+
20+
declare function f1<A extends string, B extends string>(a: A, b: B): { [P in A | B]: any };
21+
22+
function f2<A extends string>(a: A) {
23+
return f1(a, 'x');
24+
}
25+
26+
function f3(x: 'a' | 'b') {
27+
return f2(x);
28+
}

0 commit comments

Comments
 (0)