|
| 1 | +//// [tests/cases/compiler/intersectionReductionGenericStringLikeType.ts] //// |
| 2 | + |
| 3 | +=== intersectionReductionGenericStringLikeType.ts === |
| 4 | +// https://github.com/microsoft/TypeScript/issues/57736 |
| 5 | + |
| 6 | +type obj = { |
| 7 | +>obj : Symbol(obj, Decl(intersectionReductionGenericStringLikeType.ts, 0, 0)) |
| 8 | + |
| 9 | + foo: 1; |
| 10 | +>foo : Symbol(foo, Decl(intersectionReductionGenericStringLikeType.ts, 2, 12)) |
| 11 | + |
| 12 | + bar: 2; |
| 13 | +>bar : Symbol(bar, Decl(intersectionReductionGenericStringLikeType.ts, 3, 11)) |
| 14 | + |
| 15 | +}; |
| 16 | + |
| 17 | +type keyContaining1< |
| 18 | +>keyContaining1 : Symbol(keyContaining1, Decl(intersectionReductionGenericStringLikeType.ts, 5, 2)) |
| 19 | + |
| 20 | + str extends string, |
| 21 | +>str : Symbol(str, Decl(intersectionReductionGenericStringLikeType.ts, 7, 20)) |
| 22 | + |
| 23 | + keys extends keyof obj = keyof obj, |
| 24 | +>keys : Symbol(keys, Decl(intersectionReductionGenericStringLikeType.ts, 8, 23)) |
| 25 | +>obj : Symbol(obj, Decl(intersectionReductionGenericStringLikeType.ts, 0, 0)) |
| 26 | +>obj : Symbol(obj, Decl(intersectionReductionGenericStringLikeType.ts, 0, 0)) |
| 27 | + |
| 28 | +> = keys extends infer key extends keyof obj |
| 29 | +>keys : Symbol(keys, Decl(intersectionReductionGenericStringLikeType.ts, 8, 23)) |
| 30 | +>key : Symbol(key, Decl(intersectionReductionGenericStringLikeType.ts, 10, 22)) |
| 31 | +>obj : Symbol(obj, Decl(intersectionReductionGenericStringLikeType.ts, 0, 0)) |
| 32 | + |
| 33 | + ? key extends `${string}${str}${string}` |
| 34 | +>key : Symbol(key, Decl(intersectionReductionGenericStringLikeType.ts, 10, 22)) |
| 35 | +>str : Symbol(str, Decl(intersectionReductionGenericStringLikeType.ts, 7, 20)) |
| 36 | + |
| 37 | + ? obj[key] |
| 38 | +>obj : Symbol(obj, Decl(intersectionReductionGenericStringLikeType.ts, 0, 0)) |
| 39 | +>key : Symbol(key, Decl(intersectionReductionGenericStringLikeType.ts, 10, 22)) |
| 40 | + |
| 41 | + : never |
| 42 | + : never; |
| 43 | + |
| 44 | +type _1 = keyContaining1<"foo">; // 1 |
| 45 | +>_1 : Symbol(_1, Decl(intersectionReductionGenericStringLikeType.ts, 14, 12)) |
| 46 | +>keyContaining1 : Symbol(keyContaining1, Decl(intersectionReductionGenericStringLikeType.ts, 5, 2)) |
| 47 | + |
| 48 | +type keyContaining2< |
| 49 | +>keyContaining2 : Symbol(keyContaining2, Decl(intersectionReductionGenericStringLikeType.ts, 16, 32)) |
| 50 | + |
| 51 | + str extends string, |
| 52 | +>str : Symbol(str, Decl(intersectionReductionGenericStringLikeType.ts, 18, 20)) |
| 53 | + |
| 54 | + keys extends keyof obj = keyof obj, |
| 55 | +>keys : Symbol(keys, Decl(intersectionReductionGenericStringLikeType.ts, 19, 23)) |
| 56 | +>obj : Symbol(obj, Decl(intersectionReductionGenericStringLikeType.ts, 0, 0)) |
| 57 | +>obj : Symbol(obj, Decl(intersectionReductionGenericStringLikeType.ts, 0, 0)) |
| 58 | + |
| 59 | +> = keys extends keys |
| 60 | +>keys : Symbol(keys, Decl(intersectionReductionGenericStringLikeType.ts, 19, 23)) |
| 61 | +>keys : Symbol(keys, Decl(intersectionReductionGenericStringLikeType.ts, 19, 23)) |
| 62 | + |
| 63 | + ? keys extends `${string}${str}${string}` |
| 64 | +>keys : Symbol(keys, Decl(intersectionReductionGenericStringLikeType.ts, 19, 23)) |
| 65 | +>str : Symbol(str, Decl(intersectionReductionGenericStringLikeType.ts, 18, 20)) |
| 66 | + |
| 67 | + ? obj[keys] |
| 68 | +>obj : Symbol(obj, Decl(intersectionReductionGenericStringLikeType.ts, 0, 0)) |
| 69 | +>keys : Symbol(keys, Decl(intersectionReductionGenericStringLikeType.ts, 19, 23)) |
| 70 | + |
| 71 | + : never |
| 72 | + : never; |
| 73 | + |
| 74 | +type _2 = keyContaining2<"foo">; // 1 |
| 75 | +>_2 : Symbol(_2, Decl(intersectionReductionGenericStringLikeType.ts, 25, 12)) |
| 76 | +>keyContaining2 : Symbol(keyContaining2, Decl(intersectionReductionGenericStringLikeType.ts, 16, 32)) |
| 77 | + |
0 commit comments