|
| 1 | +=== tests/cases/conformance/types/union/unionTypeWithIndexSignature.ts === |
| 2 | +type Two = { foo: { bar: true }, baz: true } | { [s: string]: string }; |
| 3 | +>Two : Symbol(Two, Decl(unionTypeWithIndexSignature.ts, 0, 0)) |
| 4 | +>foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 0, 12)) |
| 5 | +>bar : Symbol(bar, Decl(unionTypeWithIndexSignature.ts, 0, 19)) |
| 6 | +>baz : Symbol(baz, Decl(unionTypeWithIndexSignature.ts, 0, 32)) |
| 7 | +>s : Symbol(s, Decl(unionTypeWithIndexSignature.ts, 0, 50)) |
| 8 | + |
| 9 | +declare var u: Two; |
| 10 | +>u : Symbol(u, Decl(unionTypeWithIndexSignature.ts, 1, 11)) |
| 11 | +>Two : Symbol(Two, Decl(unionTypeWithIndexSignature.ts, 0, 0)) |
| 12 | + |
| 13 | +u.foo = 'bye' |
| 14 | +>u.foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 0, 12)) |
| 15 | +>u : Symbol(u, Decl(unionTypeWithIndexSignature.ts, 1, 11)) |
| 16 | +>foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 0, 12)) |
| 17 | + |
| 18 | +u.baz = 'hi' |
| 19 | +>u.baz : Symbol(baz, Decl(unionTypeWithIndexSignature.ts, 0, 32)) |
| 20 | +>u : Symbol(u, Decl(unionTypeWithIndexSignature.ts, 1, 11)) |
| 21 | +>baz : Symbol(baz, Decl(unionTypeWithIndexSignature.ts, 0, 32)) |
| 22 | + |
| 23 | +type Three = { foo: number } | { [s: string]: string } | { [s: string]: boolean }; |
| 24 | +>Three : Symbol(Three, Decl(unionTypeWithIndexSignature.ts, 3, 12)) |
| 25 | +>foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 4, 14)) |
| 26 | +>s : Symbol(s, Decl(unionTypeWithIndexSignature.ts, 4, 34)) |
| 27 | +>s : Symbol(s, Decl(unionTypeWithIndexSignature.ts, 4, 60)) |
| 28 | + |
| 29 | +declare var v: Three; |
| 30 | +>v : Symbol(v, Decl(unionTypeWithIndexSignature.ts, 5, 11)) |
| 31 | +>Three : Symbol(Three, Decl(unionTypeWithIndexSignature.ts, 3, 12)) |
| 32 | + |
| 33 | +v.foo = false |
| 34 | +>v.foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 4, 14)) |
| 35 | +>v : Symbol(v, Decl(unionTypeWithIndexSignature.ts, 5, 11)) |
| 36 | +>foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 4, 14)) |
| 37 | + |
| 38 | +type Missing = { foo: number, bar: true } | { [s: string]: string } | { foo: boolean } |
| 39 | +>Missing : Symbol(Missing, Decl(unionTypeWithIndexSignature.ts, 6, 13)) |
| 40 | +>foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 7, 16)) |
| 41 | +>bar : Symbol(bar, Decl(unionTypeWithIndexSignature.ts, 7, 29)) |
| 42 | +>s : Symbol(s, Decl(unionTypeWithIndexSignature.ts, 7, 47)) |
| 43 | +>foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 7, 71)) |
| 44 | + |
| 45 | +declare var m: Missing; |
| 46 | +>m : Symbol(m, Decl(unionTypeWithIndexSignature.ts, 8, 11)) |
| 47 | +>Missing : Symbol(Missing, Decl(unionTypeWithIndexSignature.ts, 6, 13)) |
| 48 | + |
| 49 | +m.foo = 'hi' |
| 50 | +>m.foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 7, 16), Decl(unionTypeWithIndexSignature.ts, 7, 71)) |
| 51 | +>m : Symbol(m, Decl(unionTypeWithIndexSignature.ts, 8, 11)) |
| 52 | +>foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 7, 16), Decl(unionTypeWithIndexSignature.ts, 7, 71)) |
| 53 | + |
| 54 | +m.bar |
| 55 | +>m : Symbol(m, Decl(unionTypeWithIndexSignature.ts, 8, 11)) |
| 56 | + |
| 57 | +type RO = { foo: number } | { readonly [s: string]: string } |
| 58 | +>RO : Symbol(RO, Decl(unionTypeWithIndexSignature.ts, 10, 5)) |
| 59 | +>foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 11, 11)) |
| 60 | +>s : Symbol(s, Decl(unionTypeWithIndexSignature.ts, 11, 40)) |
| 61 | + |
| 62 | +declare var ro: RO; |
| 63 | +>ro : Symbol(ro, Decl(unionTypeWithIndexSignature.ts, 12, 11)) |
| 64 | +>RO : Symbol(RO, Decl(unionTypeWithIndexSignature.ts, 10, 5)) |
| 65 | + |
| 66 | +ro.foo = 'not allowed' |
| 67 | +>ro.foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 11, 11)) |
| 68 | +>ro : Symbol(ro, Decl(unionTypeWithIndexSignature.ts, 12, 11)) |
| 69 | +>foo : Symbol(foo, Decl(unionTypeWithIndexSignature.ts, 11, 11)) |
| 70 | + |
| 71 | +type Num = { '0': string } | { [n: number]: number } |
| 72 | +>Num : Symbol(Num, Decl(unionTypeWithIndexSignature.ts, 13, 22)) |
| 73 | +>'0' : Symbol('0', Decl(unionTypeWithIndexSignature.ts, 14, 12)) |
| 74 | +>n : Symbol(n, Decl(unionTypeWithIndexSignature.ts, 14, 32)) |
| 75 | + |
| 76 | +declare var num: Num; |
| 77 | +>num : Symbol(num, Decl(unionTypeWithIndexSignature.ts, 15, 11)) |
| 78 | +>Num : Symbol(Num, Decl(unionTypeWithIndexSignature.ts, 13, 22)) |
| 79 | + |
| 80 | +num[0] = 1 |
| 81 | +>num : Symbol(num, Decl(unionTypeWithIndexSignature.ts, 15, 11)) |
| 82 | +>0 : Symbol('0', Decl(unionTypeWithIndexSignature.ts, 14, 12)) |
| 83 | + |
| 84 | +num['0'] = 'ok' |
| 85 | +>num : Symbol(num, Decl(unionTypeWithIndexSignature.ts, 15, 11)) |
| 86 | +>'0' : Symbol('0', Decl(unionTypeWithIndexSignature.ts, 14, 12)) |
| 87 | + |
0 commit comments