|
| 1 | +=== tests/cases/conformance/types/intersection/intersectionTypeInference2.ts === |
| 2 | +declare function f<T>(x: { prop: T }): T; |
| 3 | +>f : Symbol(f, Decl(intersectionTypeInference2.ts, 0, 0)) |
| 4 | +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 0, 19)) |
| 5 | +>x : Symbol(x, Decl(intersectionTypeInference2.ts, 0, 22)) |
| 6 | +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 0, 26)) |
| 7 | +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 0, 19)) |
| 8 | +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 0, 19)) |
| 9 | + |
| 10 | +declare const a: { prop: string } & { prop: number }; |
| 11 | +>a : Symbol(a, Decl(intersectionTypeInference2.ts, 2, 13)) |
| 12 | +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 2, 18)) |
| 13 | +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 2, 37)) |
| 14 | + |
| 15 | +declare const b: { prop: string & number }; |
| 16 | +>b : Symbol(b, Decl(intersectionTypeInference2.ts, 3, 13)) |
| 17 | +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 3, 18)) |
| 18 | + |
| 19 | +f(a); // string & number |
| 20 | +>f : Symbol(f, Decl(intersectionTypeInference2.ts, 0, 0)) |
| 21 | +>a : Symbol(a, Decl(intersectionTypeInference2.ts, 2, 13)) |
| 22 | + |
| 23 | +f(b); // string & number |
| 24 | +>f : Symbol(f, Decl(intersectionTypeInference2.ts, 0, 0)) |
| 25 | +>b : Symbol(b, Decl(intersectionTypeInference2.ts, 3, 13)) |
| 26 | + |
| 27 | +// Repro from #18354 |
| 28 | + |
| 29 | +declare function f2<T, Key extends keyof T>(obj: {[K in keyof T]: T[K]}, key: Key): T[Key]; |
| 30 | +>f2 : Symbol(f2, Decl(intersectionTypeInference2.ts, 6, 5)) |
| 31 | +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) |
| 32 | +>Key : Symbol(Key, Decl(intersectionTypeInference2.ts, 10, 22)) |
| 33 | +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) |
| 34 | +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 10, 44)) |
| 35 | +>K : Symbol(K, Decl(intersectionTypeInference2.ts, 10, 51)) |
| 36 | +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) |
| 37 | +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) |
| 38 | +>K : Symbol(K, Decl(intersectionTypeInference2.ts, 10, 51)) |
| 39 | +>key : Symbol(key, Decl(intersectionTypeInference2.ts, 10, 72)) |
| 40 | +>Key : Symbol(Key, Decl(intersectionTypeInference2.ts, 10, 22)) |
| 41 | +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) |
| 42 | +>Key : Symbol(Key, Decl(intersectionTypeInference2.ts, 10, 22)) |
| 43 | + |
| 44 | +declare const obj: { a: string } & { b: string }; |
| 45 | +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 12, 13)) |
| 46 | +>a : Symbol(a, Decl(intersectionTypeInference2.ts, 12, 20)) |
| 47 | +>b : Symbol(b, Decl(intersectionTypeInference2.ts, 12, 36)) |
| 48 | + |
| 49 | +f2(obj, 'a'); |
| 50 | +>f2 : Symbol(f2, Decl(intersectionTypeInference2.ts, 6, 5)) |
| 51 | +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 12, 13)) |
| 52 | + |
| 53 | +f2(obj, 'b'); |
| 54 | +>f2 : Symbol(f2, Decl(intersectionTypeInference2.ts, 6, 5)) |
| 55 | +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 12, 13)) |
| 56 | + |
0 commit comments