Add tests
This commit is contained in:
parent
5895057578
commit
9cb14feef5
1 changed files with 28 additions and 0 deletions
28
tests/cases/compiler/deferredLookupTypeResolution.ts
Normal file
28
tests/cases/compiler/deferredLookupTypeResolution.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
// @strict: true
|
||||
// @declaration: true
|
||||
|
||||
// Repro from #17456
|
||||
|
||||
type StringContains<S extends string, L extends string> = (
|
||||
{ [K in S]: 'true' } &
|
||||
{ [key: string]: 'false' }
|
||||
)[L]
|
||||
|
||||
type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>
|
||||
|
||||
type First<T> = ObjectHasKey<T, '0'>; // Should be deferred
|
||||
|
||||
type T1 = ObjectHasKey<{ a: string }, 'a'>; // 'true'
|
||||
type T2 = ObjectHasKey<{ a: string }, 'b'>; // 'false'
|
||||
|
||||
// Verify that mapped type isn't eagerly resolved in type-to-string operation
|
||||
|
||||
declare function f1<A extends string, B extends string>(a: A, b: B): { [P in A | B]: any };
|
||||
|
||||
function f2<A extends string>(a: A) {
|
||||
return f1(a, 'x');
|
||||
}
|
||||
|
||||
function f3(x: 'a' | 'b') {
|
||||
return f2(x);
|
||||
}
|
Loading…
Reference in a new issue