|
| 1 | +=== tests/cases/conformance/types/intersection/intersectionWithIndexSignatures.ts === |
| 2 | +type A = { a: string }; |
| 3 | +>A : Symbol(A, Decl(intersectionWithIndexSignatures.ts, 0, 0)) |
| 4 | +>a : Symbol(a, Decl(intersectionWithIndexSignatures.ts, 0, 10)) |
| 5 | + |
| 6 | +type B = { b: string }; |
| 7 | +>B : Symbol(B, Decl(intersectionWithIndexSignatures.ts, 0, 23)) |
| 8 | +>b : Symbol(b, Decl(intersectionWithIndexSignatures.ts, 1, 10)) |
| 9 | + |
| 10 | +declare let sa1: { x: A & B }; |
| 11 | +>sa1 : Symbol(sa1, Decl(intersectionWithIndexSignatures.ts, 3, 11)) |
| 12 | +>x : Symbol(x, Decl(intersectionWithIndexSignatures.ts, 3, 18)) |
| 13 | +>A : Symbol(A, Decl(intersectionWithIndexSignatures.ts, 0, 0)) |
| 14 | +>B : Symbol(B, Decl(intersectionWithIndexSignatures.ts, 0, 23)) |
| 15 | + |
| 16 | +declare let sa2: { x: A } & { x: B }; |
| 17 | +>sa2 : Symbol(sa2, Decl(intersectionWithIndexSignatures.ts, 4, 11)) |
| 18 | +>x : Symbol(x, Decl(intersectionWithIndexSignatures.ts, 4, 18)) |
| 19 | +>A : Symbol(A, Decl(intersectionWithIndexSignatures.ts, 0, 0)) |
| 20 | +>x : Symbol(x, Decl(intersectionWithIndexSignatures.ts, 4, 29)) |
| 21 | +>B : Symbol(B, Decl(intersectionWithIndexSignatures.ts, 0, 23)) |
| 22 | + |
| 23 | +declare let ta1: { [key: string]: A & B }; |
| 24 | +>ta1 : Symbol(ta1, Decl(intersectionWithIndexSignatures.ts, 5, 11)) |
| 25 | +>key : Symbol(key, Decl(intersectionWithIndexSignatures.ts, 5, 20)) |
| 26 | +>A : Symbol(A, Decl(intersectionWithIndexSignatures.ts, 0, 0)) |
| 27 | +>B : Symbol(B, Decl(intersectionWithIndexSignatures.ts, 0, 23)) |
| 28 | + |
| 29 | +declare let ta2: { [key: string]: A } & { [key: string]: B }; |
| 30 | +>ta2 : Symbol(ta2, Decl(intersectionWithIndexSignatures.ts, 6, 11)) |
| 31 | +>key : Symbol(key, Decl(intersectionWithIndexSignatures.ts, 6, 20)) |
| 32 | +>A : Symbol(A, Decl(intersectionWithIndexSignatures.ts, 0, 0)) |
| 33 | +>key : Symbol(key, Decl(intersectionWithIndexSignatures.ts, 6, 43)) |
| 34 | +>B : Symbol(B, Decl(intersectionWithIndexSignatures.ts, 0, 23)) |
| 35 | + |
| 36 | +ta1 = sa1; |
| 37 | +>ta1 : Symbol(ta1, Decl(intersectionWithIndexSignatures.ts, 5, 11)) |
| 38 | +>sa1 : Symbol(sa1, Decl(intersectionWithIndexSignatures.ts, 3, 11)) |
| 39 | + |
| 40 | +ta1 = sa2; |
| 41 | +>ta1 : Symbol(ta1, Decl(intersectionWithIndexSignatures.ts, 5, 11)) |
| 42 | +>sa2 : Symbol(sa2, Decl(intersectionWithIndexSignatures.ts, 4, 11)) |
| 43 | + |
| 44 | +ta2 = sa1; |
| 45 | +>ta2 : Symbol(ta2, Decl(intersectionWithIndexSignatures.ts, 6, 11)) |
| 46 | +>sa1 : Symbol(sa1, Decl(intersectionWithIndexSignatures.ts, 3, 11)) |
| 47 | + |
| 48 | +ta2 = sa2; |
| 49 | +>ta2 : Symbol(ta2, Decl(intersectionWithIndexSignatures.ts, 6, 11)) |
| 50 | +>sa2 : Symbol(sa2, Decl(intersectionWithIndexSignatures.ts, 4, 11)) |
| 51 | + |
| 52 | +declare let sb1: { x: A } & { y: B }; |
| 53 | +>sb1 : Symbol(sb1, Decl(intersectionWithIndexSignatures.ts, 13, 11)) |
| 54 | +>x : Symbol(x, Decl(intersectionWithIndexSignatures.ts, 13, 18)) |
| 55 | +>A : Symbol(A, Decl(intersectionWithIndexSignatures.ts, 0, 0)) |
| 56 | +>y : Symbol(y, Decl(intersectionWithIndexSignatures.ts, 13, 29)) |
| 57 | +>B : Symbol(B, Decl(intersectionWithIndexSignatures.ts, 0, 23)) |
| 58 | + |
| 59 | +declare let tb1: { [key: string]: A }; |
| 60 | +>tb1 : Symbol(tb1, Decl(intersectionWithIndexSignatures.ts, 14, 11)) |
| 61 | +>key : Symbol(key, Decl(intersectionWithIndexSignatures.ts, 14, 20)) |
| 62 | +>A : Symbol(A, Decl(intersectionWithIndexSignatures.ts, 0, 0)) |
| 63 | + |
| 64 | +tb1 = sb1; // Error |
| 65 | +>tb1 : Symbol(tb1, Decl(intersectionWithIndexSignatures.ts, 14, 11)) |
| 66 | +>sb1 : Symbol(sb1, Decl(intersectionWithIndexSignatures.ts, 13, 11)) |
| 67 | + |
| 68 | +// Repro from #32484 |
| 69 | + |
| 70 | +type constr<Source, Tgt> = { [K in keyof Source]: string } & Pick<Tgt, Exclude<keyof Tgt, keyof Source>>; |
| 71 | +>constr : Symbol(constr, Decl(intersectionWithIndexSignatures.ts, 16, 10)) |
| 72 | +>Source : Symbol(Source, Decl(intersectionWithIndexSignatures.ts, 20, 12)) |
| 73 | +>Tgt : Symbol(Tgt, Decl(intersectionWithIndexSignatures.ts, 20, 19)) |
| 74 | +>K : Symbol(K, Decl(intersectionWithIndexSignatures.ts, 20, 30)) |
| 75 | +>Source : Symbol(Source, Decl(intersectionWithIndexSignatures.ts, 20, 12)) |
| 76 | +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) |
| 77 | +>Tgt : Symbol(Tgt, Decl(intersectionWithIndexSignatures.ts, 20, 19)) |
| 78 | +>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) |
| 79 | +>Tgt : Symbol(Tgt, Decl(intersectionWithIndexSignatures.ts, 20, 19)) |
| 80 | +>Source : Symbol(Source, Decl(intersectionWithIndexSignatures.ts, 20, 12)) |
| 81 | + |
| 82 | +type s = constr<{}, { [key: string]: { a: string } }>; |
| 83 | +>s : Symbol(s, Decl(intersectionWithIndexSignatures.ts, 20, 105)) |
| 84 | +>constr : Symbol(constr, Decl(intersectionWithIndexSignatures.ts, 16, 10)) |
| 85 | +>key : Symbol(key, Decl(intersectionWithIndexSignatures.ts, 22, 23)) |
| 86 | +>a : Symbol(a, Decl(intersectionWithIndexSignatures.ts, 22, 38)) |
| 87 | + |
| 88 | +declare const q: s; |
| 89 | +>q : Symbol(q, Decl(intersectionWithIndexSignatures.ts, 24, 13)) |
| 90 | +>s : Symbol(s, Decl(intersectionWithIndexSignatures.ts, 20, 105)) |
| 91 | + |
| 92 | +q["asd"].a.substr(1); |
| 93 | +>q["asd"].a.substr : Symbol(String.substr, Decl(lib.es5.d.ts, --, --)) |
| 94 | +>q["asd"].a : Symbol(a, Decl(intersectionWithIndexSignatures.ts, 22, 38)) |
| 95 | +>q : Symbol(q, Decl(intersectionWithIndexSignatures.ts, 24, 13)) |
| 96 | +>a : Symbol(a, Decl(intersectionWithIndexSignatures.ts, 22, 38)) |
| 97 | +>substr : Symbol(String.substr, Decl(lib.es5.d.ts, --, --)) |
| 98 | + |
| 99 | +q["asd"].b; // Error |
| 100 | +>q : Symbol(q, Decl(intersectionWithIndexSignatures.ts, 24, 13)) |
| 101 | + |
| 102 | +const d: { [key: string]: {a: string, b: string} } = q; // Error |
| 103 | +>d : Symbol(d, Decl(intersectionWithIndexSignatures.ts, 28, 5)) |
| 104 | +>key : Symbol(key, Decl(intersectionWithIndexSignatures.ts, 28, 12)) |
| 105 | +>a : Symbol(a, Decl(intersectionWithIndexSignatures.ts, 28, 27)) |
| 106 | +>b : Symbol(b, Decl(intersectionWithIndexSignatures.ts, 28, 37)) |
| 107 | +>q : Symbol(q, Decl(intersectionWithIndexSignatures.ts, 24, 13)) |
| 108 | + |
| 109 | +// Repro from #32484 |
| 110 | + |
| 111 | +declare let ss: { a: string } & { b: number }; |
| 112 | +>ss : Symbol(ss, Decl(intersectionWithIndexSignatures.ts, 32, 11)) |
| 113 | +>a : Symbol(a, Decl(intersectionWithIndexSignatures.ts, 32, 17)) |
| 114 | +>b : Symbol(b, Decl(intersectionWithIndexSignatures.ts, 32, 33)) |
| 115 | + |
| 116 | +declare let tt: { [key: string]: string }; |
| 117 | +>tt : Symbol(tt, Decl(intersectionWithIndexSignatures.ts, 33, 11)) |
| 118 | +>key : Symbol(key, Decl(intersectionWithIndexSignatures.ts, 33, 19)) |
| 119 | + |
| 120 | +tt = ss; // Error |
| 121 | +>tt : Symbol(tt, Decl(intersectionWithIndexSignatures.ts, 33, 11)) |
| 122 | +>ss : Symbol(ss, Decl(intersectionWithIndexSignatures.ts, 32, 11)) |
| 123 | + |
0 commit comments