diff --git a/tests/baselines/reference/destructuringSameNames.errors.txt b/tests/baselines/reference/destructuringSameNames.errors.txt new file mode 100644 index 00000000000..54055285852 --- /dev/null +++ b/tests/baselines/reference/destructuringSameNames.errors.txt @@ -0,0 +1,81 @@ +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(21,7): error TS2451: Cannot redeclare block-scoped variable 'foo1'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(21,13): error TS2451: Cannot redeclare block-scoped variable 'foo1'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(22,7): error TS2451: Cannot redeclare block-scoped variable 'foo2'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(22,19): error TS2451: Cannot redeclare block-scoped variable 'foo2'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(23,13): error TS2451: Cannot redeclare block-scoped variable 'foo3'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(23,19): error TS2451: Cannot redeclare block-scoped variable 'foo3'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(24,9): error TS2451: Cannot redeclare block-scoped variable 'foo4'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(24,15): error TS2451: Cannot redeclare block-scoped variable 'foo4'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(25,9): error TS2451: Cannot redeclare block-scoped variable 'foo5'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(25,21): error TS2451: Cannot redeclare block-scoped variable 'foo5'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(26,15): error TS2451: Cannot redeclare block-scoped variable 'foo6'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(26,21): error TS2451: Cannot redeclare block-scoped variable 'foo6'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(28,6): error TS2451: Cannot redeclare block-scoped variable 'blah1'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(28,13): error TS2451: Cannot redeclare block-scoped variable 'blah1'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(29,8): error TS2451: Cannot redeclare block-scoped variable 'blah2'. +tests/cases/conformance/es6/destructuring/destructuringSameNames.ts(29,15): error TS2451: Cannot redeclare block-scoped variable 'blah2'. + + +==== tests/cases/conformance/es6/destructuring/destructuringSameNames.ts (16 errors) ==== + // Valid cases + + let { foo, foo: bar } = { foo: 1 }; + ({ foo, foo } = { foo: 2 }); + ({ foo, foo: bar } = { foo: 3 }); + ({ foo: bar, foo } = { foo: 4 }); + ({ foo, bar: foo } = { foo: 3, bar: 33 }); + ({ bar: foo, foo } = { foo: 4, bar: 44 }); + ({ foo: bar, foo: bar } = { foo: 5 }); + ({ foo: bar, bar: foo } = { foo: 6, bar: 66 }); + ({ foo: bar, foo: bar } = { foo: 7 }); + + [foo, foo] = [111, 1111]; + [foo, foo] = [222, 2222]; + [bar, foo, foo] = [333, 3333, 33333]; + [foo, bar, foo] = [333, 3333, 33333]; + [foo, foo, bar] = [444, 4444, 44444]; + + // Error cases + + let { foo1, foo1 } = { foo1: 10 }; + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo1'. + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo1'. + let { foo2, bar2: foo2 } = { foo2: 20, bar2: 220 }; + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo2'. + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo2'. + let { bar3: foo3, foo3 } = { foo3: 30, bar3: 330 }; + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo3'. + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo3'. + const { foo4, foo4 } = { foo4: 40 }; + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo4'. + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo4'. + const { foo5, bar5: foo5 } = { foo5: 50, bar5: 550 }; + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo5'. + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo5'. + const { bar6: foo6, foo6 } = { foo6: 60, bar6: 660 }; + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo6'. + ~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo6'. + + let [blah1, blah1] = [111, 222]; + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'blah1'. + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'blah1'. + const [blah2, blah2] = [333, 444]; + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'blah2'. + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'blah2'. + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringSameNames.js b/tests/baselines/reference/destructuringSameNames.js new file mode 100644 index 00000000000..1fc34e099f9 --- /dev/null +++ b/tests/baselines/reference/destructuringSameNames.js @@ -0,0 +1,58 @@ +//// [destructuringSameNames.ts] +// Valid cases + +let { foo, foo: bar } = { foo: 1 }; +({ foo, foo } = { foo: 2 }); +({ foo, foo: bar } = { foo: 3 }); +({ foo: bar, foo } = { foo: 4 }); +({ foo, bar: foo } = { foo: 3, bar: 33 }); +({ bar: foo, foo } = { foo: 4, bar: 44 }); +({ foo: bar, foo: bar } = { foo: 5 }); +({ foo: bar, bar: foo } = { foo: 6, bar: 66 }); +({ foo: bar, foo: bar } = { foo: 7 }); + +[foo, foo] = [111, 1111]; +[foo, foo] = [222, 2222]; +[bar, foo, foo] = [333, 3333, 33333]; +[foo, bar, foo] = [333, 3333, 33333]; +[foo, foo, bar] = [444, 4444, 44444]; + +// Error cases + +let { foo1, foo1 } = { foo1: 10 }; +let { foo2, bar2: foo2 } = { foo2: 20, bar2: 220 }; +let { bar3: foo3, foo3 } = { foo3: 30, bar3: 330 }; +const { foo4, foo4 } = { foo4: 40 }; +const { foo5, bar5: foo5 } = { foo5: 50, bar5: 550 }; +const { bar6: foo6, foo6 } = { foo6: 60, bar6: 660 }; + +let [blah1, blah1] = [111, 222]; +const [blah2, blah2] = [333, 444]; + + +//// [destructuringSameNames.js] +// Valid cases +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; +var _p = { foo: 1 }, foo = _p.foo, bar = _p.foo; +(_a = { foo: 2 }, foo = _a.foo, foo = _a.foo); +(_b = { foo: 3 }, foo = _b.foo, bar = _b.foo); +(_c = { foo: 4 }, bar = _c.foo, foo = _c.foo); +(_d = { foo: 3, bar: 33 }, foo = _d.foo, foo = _d.bar); +(_e = { foo: 4, bar: 44 }, foo = _e.bar, foo = _e.foo); +(_f = { foo: 5 }, bar = _f.foo, bar = _f.foo); +(_g = { foo: 6, bar: 66 }, bar = _g.foo, foo = _g.bar); +(_h = { foo: 7 }, bar = _h.foo, bar = _h.foo); +_j = [111, 1111], foo = _j[0], foo = _j[1]; +_k = [222, 2222], foo = _k[0], foo = _k[1]; +_l = [333, 3333, 33333], bar = _l[0], foo = _l[1], foo = _l[2]; +_m = [333, 3333, 33333], foo = _m[0], bar = _m[1], foo = _m[2]; +_o = [444, 4444, 44444], foo = _o[0], foo = _o[1], bar = _o[2]; +// Error cases +var _q = { foo1: 10 }, foo1 = _q.foo1, foo1 = _q.foo1; +var _r = { foo2: 20, bar2: 220 }, foo2 = _r.foo2, foo2 = _r.bar2; +var _s = { foo3: 30, bar3: 330 }, foo3 = _s.bar3, foo3 = _s.foo3; +var _t = { foo4: 40 }, foo4 = _t.foo4, foo4 = _t.foo4; +var _u = { foo5: 50, bar5: 550 }, foo5 = _u.foo5, foo5 = _u.bar5; +var _v = { foo6: 60, bar6: 660 }, foo6 = _v.bar6, foo6 = _v.foo6; +var _w = [111, 222], blah1 = _w[0], blah1 = _w[1]; +var _x = [333, 444], blah2 = _x[0], blah2 = _x[1]; diff --git a/tests/baselines/reference/destructuringSameNames.symbols b/tests/baselines/reference/destructuringSameNames.symbols new file mode 100644 index 00000000000..4b210bbfde3 --- /dev/null +++ b/tests/baselines/reference/destructuringSameNames.symbols @@ -0,0 +1,133 @@ +=== tests/cases/conformance/es6/destructuring/destructuringSameNames.ts === +// Valid cases + +let { foo, foo: bar } = { foo: 1 }; +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 25)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 2, 10)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 25)) + +({ foo, foo } = { foo: 2 }); +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 3, 2), Decl(destructuringSameNames.ts, 3, 7)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 3, 2), Decl(destructuringSameNames.ts, 3, 7)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 3, 17)) + +({ foo, foo: bar } = { foo: 3 }); +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 4, 2), Decl(destructuringSameNames.ts, 4, 7)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 4, 2), Decl(destructuringSameNames.ts, 4, 7)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 2, 10)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 4, 22)) + +({ foo: bar, foo } = { foo: 4 }); +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 5, 2), Decl(destructuringSameNames.ts, 5, 12)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 2, 10)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 5, 2), Decl(destructuringSameNames.ts, 5, 12)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 5, 22)) + +({ foo, bar: foo } = { foo: 3, bar: 33 }); +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 6, 2)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 6, 7)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 6, 22)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 6, 30)) + +({ bar: foo, foo } = { foo: 4, bar: 44 }); +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 7, 2)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 7, 12)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 7, 22)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 7, 30)) + +({ foo: bar, foo: bar } = { foo: 5 }); +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 8, 2), Decl(destructuringSameNames.ts, 8, 12)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 2, 10)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 8, 2), Decl(destructuringSameNames.ts, 8, 12)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 2, 10)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 8, 27)) + +({ foo: bar, bar: foo } = { foo: 6, bar: 66 }); +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 9, 2)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 2, 10)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 9, 12)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 9, 27)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 9, 35)) + +({ foo: bar, foo: bar } = { foo: 7 }); +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 10, 2), Decl(destructuringSameNames.ts, 10, 12)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 2, 10)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 10, 2), Decl(destructuringSameNames.ts, 10, 12)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 2, 10)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 10, 27)) + +[foo, foo] = [111, 1111]; +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) + +[foo, foo] = [222, 2222]; +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) + +[bar, foo, foo] = [333, 3333, 33333]; +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 2, 10)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) + +[foo, bar, foo] = [333, 3333, 33333]; +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 2, 10)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) + +[foo, foo, bar] = [444, 4444, 44444]; +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) +>foo : Symbol(foo, Decl(destructuringSameNames.ts, 2, 5)) +>bar : Symbol(bar, Decl(destructuringSameNames.ts, 2, 10)) + +// Error cases + +let { foo1, foo1 } = { foo1: 10 }; +>foo1 : Symbol(foo1, Decl(destructuringSameNames.ts, 20, 5)) +>foo1 : Symbol(foo1, Decl(destructuringSameNames.ts, 20, 11)) +>foo1 : Symbol(foo1, Decl(destructuringSameNames.ts, 20, 22)) + +let { foo2, bar2: foo2 } = { foo2: 20, bar2: 220 }; +>foo2 : Symbol(foo2, Decl(destructuringSameNames.ts, 21, 5)) +>bar2 : Symbol(bar2, Decl(destructuringSameNames.ts, 21, 38)) +>foo2 : Symbol(foo2, Decl(destructuringSameNames.ts, 21, 11)) +>foo2 : Symbol(foo2, Decl(destructuringSameNames.ts, 21, 28)) +>bar2 : Symbol(bar2, Decl(destructuringSameNames.ts, 21, 38)) + +let { bar3: foo3, foo3 } = { foo3: 30, bar3: 330 }; +>bar3 : Symbol(bar3, Decl(destructuringSameNames.ts, 22, 38)) +>foo3 : Symbol(foo3, Decl(destructuringSameNames.ts, 22, 5)) +>foo3 : Symbol(foo3, Decl(destructuringSameNames.ts, 22, 17)) +>foo3 : Symbol(foo3, Decl(destructuringSameNames.ts, 22, 28)) +>bar3 : Symbol(bar3, Decl(destructuringSameNames.ts, 22, 38)) + +const { foo4, foo4 } = { foo4: 40 }; +>foo4 : Symbol(foo4, Decl(destructuringSameNames.ts, 23, 7)) +>foo4 : Symbol(foo4, Decl(destructuringSameNames.ts, 23, 13)) +>foo4 : Symbol(foo4, Decl(destructuringSameNames.ts, 23, 24)) + +const { foo5, bar5: foo5 } = { foo5: 50, bar5: 550 }; +>foo5 : Symbol(foo5, Decl(destructuringSameNames.ts, 24, 7)) +>bar5 : Symbol(bar5, Decl(destructuringSameNames.ts, 24, 40)) +>foo5 : Symbol(foo5, Decl(destructuringSameNames.ts, 24, 13)) +>foo5 : Symbol(foo5, Decl(destructuringSameNames.ts, 24, 30)) +>bar5 : Symbol(bar5, Decl(destructuringSameNames.ts, 24, 40)) + +const { bar6: foo6, foo6 } = { foo6: 60, bar6: 660 }; +>bar6 : Symbol(bar6, Decl(destructuringSameNames.ts, 25, 40)) +>foo6 : Symbol(foo6, Decl(destructuringSameNames.ts, 25, 7)) +>foo6 : Symbol(foo6, Decl(destructuringSameNames.ts, 25, 19)) +>foo6 : Symbol(foo6, Decl(destructuringSameNames.ts, 25, 30)) +>bar6 : Symbol(bar6, Decl(destructuringSameNames.ts, 25, 40)) + +let [blah1, blah1] = [111, 222]; +>blah1 : Symbol(blah1, Decl(destructuringSameNames.ts, 27, 5)) +>blah1 : Symbol(blah1, Decl(destructuringSameNames.ts, 27, 11)) + +const [blah2, blah2] = [333, 444]; +>blah2 : Symbol(blah2, Decl(destructuringSameNames.ts, 28, 7)) +>blah2 : Symbol(blah2, Decl(destructuringSameNames.ts, 28, 13)) + diff --git a/tests/baselines/reference/destructuringSameNames.types b/tests/baselines/reference/destructuringSameNames.types new file mode 100644 index 00000000000..9769401e0ec --- /dev/null +++ b/tests/baselines/reference/destructuringSameNames.types @@ -0,0 +1,228 @@ +=== tests/cases/conformance/es6/destructuring/destructuringSameNames.ts === +// Valid cases + +let { foo, foo: bar } = { foo: 1 }; +>foo : number +>foo : any +>bar : number +>{ foo: 1 } : { foo: number; } +>foo : number +>1 : 1 + +({ foo, foo } = { foo: 2 }); +>({ foo, foo } = { foo: 2 }) : { foo: number; } +>{ foo, foo } = { foo: 2 } : { foo: number; } +>{ foo, foo } : { foo: number; } +>foo : number +>foo : number +>{ foo: 2 } : { foo: number; } +>foo : number +>2 : 2 + +({ foo, foo: bar } = { foo: 3 }); +>({ foo, foo: bar } = { foo: 3 }) : { foo: number; } +>{ foo, foo: bar } = { foo: 3 } : { foo: number; } +>{ foo, foo: bar } : { foo: number; } +>foo : number +>foo : number +>bar : number +>{ foo: 3 } : { foo: number; } +>foo : number +>3 : 3 + +({ foo: bar, foo } = { foo: 4 }); +>({ foo: bar, foo } = { foo: 4 }) : { foo: number; } +>{ foo: bar, foo } = { foo: 4 } : { foo: number; } +>{ foo: bar, foo } : { foo: number; } +>foo : number +>bar : number +>foo : number +>{ foo: 4 } : { foo: number; } +>foo : number +>4 : 4 + +({ foo, bar: foo } = { foo: 3, bar: 33 }); +>({ foo, bar: foo } = { foo: 3, bar: 33 }) : { foo: number; bar: number; } +>{ foo, bar: foo } = { foo: 3, bar: 33 } : { foo: number; bar: number; } +>{ foo, bar: foo } : { foo: number; bar: number; } +>foo : number +>bar : number +>foo : number +>{ foo: 3, bar: 33 } : { foo: number; bar: number; } +>foo : number +>3 : 3 +>bar : number +>33 : 33 + +({ bar: foo, foo } = { foo: 4, bar: 44 }); +>({ bar: foo, foo } = { foo: 4, bar: 44 }) : { foo: number; bar: number; } +>{ bar: foo, foo } = { foo: 4, bar: 44 } : { foo: number; bar: number; } +>{ bar: foo, foo } : { bar: number; foo: number; } +>bar : number +>foo : number +>foo : number +>{ foo: 4, bar: 44 } : { foo: number; bar: number; } +>foo : number +>4 : 4 +>bar : number +>44 : 44 + +({ foo: bar, foo: bar } = { foo: 5 }); +>({ foo: bar, foo: bar } = { foo: 5 }) : { foo: number; } +>{ foo: bar, foo: bar } = { foo: 5 } : { foo: number; } +>{ foo: bar, foo: bar } : { foo: number; } +>foo : number +>bar : number +>foo : number +>bar : number +>{ foo: 5 } : { foo: number; } +>foo : number +>5 : 5 + +({ foo: bar, bar: foo } = { foo: 6, bar: 66 }); +>({ foo: bar, bar: foo } = { foo: 6, bar: 66 }) : { foo: number; bar: number; } +>{ foo: bar, bar: foo } = { foo: 6, bar: 66 } : { foo: number; bar: number; } +>{ foo: bar, bar: foo } : { foo: number; bar: number; } +>foo : number +>bar : number +>bar : number +>foo : number +>{ foo: 6, bar: 66 } : { foo: number; bar: number; } +>foo : number +>6 : 6 +>bar : number +>66 : 66 + +({ foo: bar, foo: bar } = { foo: 7 }); +>({ foo: bar, foo: bar } = { foo: 7 }) : { foo: number; } +>{ foo: bar, foo: bar } = { foo: 7 } : { foo: number; } +>{ foo: bar, foo: bar } : { foo: number; } +>foo : number +>bar : number +>foo : number +>bar : number +>{ foo: 7 } : { foo: number; } +>foo : number +>7 : 7 + +[foo, foo] = [111, 1111]; +>[foo, foo] = [111, 1111] : [number, number] +>[foo, foo] : [number, number] +>foo : number +>foo : number +>[111, 1111] : [number, number] +>111 : 111 +>1111 : 1111 + +[foo, foo] = [222, 2222]; +>[foo, foo] = [222, 2222] : [number, number] +>[foo, foo] : [number, number] +>foo : number +>foo : number +>[222, 2222] : [number, number] +>222 : 222 +>2222 : 2222 + +[bar, foo, foo] = [333, 3333, 33333]; +>[bar, foo, foo] = [333, 3333, 33333] : [number, number, number] +>[bar, foo, foo] : [number, number, number] +>bar : number +>foo : number +>foo : number +>[333, 3333, 33333] : [number, number, number] +>333 : 333 +>3333 : 3333 +>33333 : 33333 + +[foo, bar, foo] = [333, 3333, 33333]; +>[foo, bar, foo] = [333, 3333, 33333] : [number, number, number] +>[foo, bar, foo] : [number, number, number] +>foo : number +>bar : number +>foo : number +>[333, 3333, 33333] : [number, number, number] +>333 : 333 +>3333 : 3333 +>33333 : 33333 + +[foo, foo, bar] = [444, 4444, 44444]; +>[foo, foo, bar] = [444, 4444, 44444] : [number, number, number] +>[foo, foo, bar] : [number, number, number] +>foo : number +>foo : number +>bar : number +>[444, 4444, 44444] : [number, number, number] +>444 : 444 +>4444 : 4444 +>44444 : 44444 + +// Error cases + +let { foo1, foo1 } = { foo1: 10 }; +>foo1 : number +>foo1 : number +>{ foo1: 10 } : { foo1: number; } +>foo1 : number +>10 : 10 + +let { foo2, bar2: foo2 } = { foo2: 20, bar2: 220 }; +>foo2 : number +>bar2 : any +>foo2 : number +>{ foo2: 20, bar2: 220 } : { foo2: number; bar2: number; } +>foo2 : number +>20 : 20 +>bar2 : number +>220 : 220 + +let { bar3: foo3, foo3 } = { foo3: 30, bar3: 330 }; +>bar3 : any +>foo3 : number +>foo3 : number +>{ foo3: 30, bar3: 330 } : { foo3: number; bar3: number; } +>foo3 : number +>30 : 30 +>bar3 : number +>330 : 330 + +const { foo4, foo4 } = { foo4: 40 }; +>foo4 : number +>foo4 : number +>{ foo4: 40 } : { foo4: number; } +>foo4 : number +>40 : 40 + +const { foo5, bar5: foo5 } = { foo5: 50, bar5: 550 }; +>foo5 : number +>bar5 : any +>foo5 : number +>{ foo5: 50, bar5: 550 } : { foo5: number; bar5: number; } +>foo5 : number +>50 : 50 +>bar5 : number +>550 : 550 + +const { bar6: foo6, foo6 } = { foo6: 60, bar6: 660 }; +>bar6 : any +>foo6 : number +>foo6 : number +>{ foo6: 60, bar6: 660 } : { foo6: number; bar6: number; } +>foo6 : number +>60 : 60 +>bar6 : number +>660 : 660 + +let [blah1, blah1] = [111, 222]; +>blah1 : number +>blah1 : number +>[111, 222] : [number, number] +>111 : 111 +>222 : 222 + +const [blah2, blah2] = [333, 444]; +>blah2 : number +>blah2 : number +>[333, 444] : [number, number] +>333 : 333 +>444 : 444 + diff --git a/tests/baselines/reference/destructuringSamePropertyTwice.js b/tests/baselines/reference/destructuringSamePropertyTwice.js deleted file mode 100644 index 3ee73c55b2d..00000000000 --- a/tests/baselines/reference/destructuringSamePropertyTwice.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [destructuringSamePropertyTwice.ts] -'use strict'; -let { foo, foo: bar } = { foo: 1 }; -({ foo, foo: bar } = { foo: 2 }); - -//// [destructuringSamePropertyTwice.js] -'use strict'; -var _a; -var _b = { foo: 1 }, foo = _b.foo, bar = _b.foo; -(_a = { foo: 2 }, foo = _a.foo, bar = _a.foo); diff --git a/tests/baselines/reference/destructuringSamePropertyTwice.symbols b/tests/baselines/reference/destructuringSamePropertyTwice.symbols deleted file mode 100644 index d17e32f9e1e..00000000000 --- a/tests/baselines/reference/destructuringSamePropertyTwice.symbols +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/destructuringSamePropertyTwice.ts === -'use strict'; -let { foo, foo: bar } = { foo: 1 }; ->foo : Symbol(foo, Decl(destructuringSamePropertyTwice.ts, 1, 5)) ->foo : Symbol(foo, Decl(destructuringSamePropertyTwice.ts, 1, 25)) ->bar : Symbol(bar, Decl(destructuringSamePropertyTwice.ts, 1, 10)) ->foo : Symbol(foo, Decl(destructuringSamePropertyTwice.ts, 1, 25)) - -({ foo, foo: bar } = { foo: 2 }); ->foo : Symbol(foo, Decl(destructuringSamePropertyTwice.ts, 2, 2), Decl(destructuringSamePropertyTwice.ts, 2, 7)) ->foo : Symbol(foo, Decl(destructuringSamePropertyTwice.ts, 2, 2), Decl(destructuringSamePropertyTwice.ts, 2, 7)) ->bar : Symbol(bar, Decl(destructuringSamePropertyTwice.ts, 1, 10)) ->foo : Symbol(foo, Decl(destructuringSamePropertyTwice.ts, 2, 22)) - diff --git a/tests/baselines/reference/destructuringSamePropertyTwice.types b/tests/baselines/reference/destructuringSamePropertyTwice.types deleted file mode 100644 index 32261452f0d..00000000000 --- a/tests/baselines/reference/destructuringSamePropertyTwice.types +++ /dev/null @@ -1,23 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/destructuringSamePropertyTwice.ts === -'use strict'; ->'use strict' : "use strict" - -let { foo, foo: bar } = { foo: 1 }; ->foo : number ->foo : any ->bar : number ->{ foo: 1 } : { foo: number; } ->foo : number ->1 : 1 - -({ foo, foo: bar } = { foo: 2 }); ->({ foo, foo: bar } = { foo: 2 }) : { foo: number; } ->{ foo, foo: bar } = { foo: 2 } : { foo: number; } ->{ foo, foo: bar } : { foo: number; } ->foo : number ->foo : number ->bar : number ->{ foo: 2 } : { foo: number; } ->foo : number ->2 : 2 - diff --git a/tests/cases/conformance/es6/destructuring/destructuringSameNames.ts b/tests/cases/conformance/es6/destructuring/destructuringSameNames.ts new file mode 100644 index 00000000000..92b8f0a9b89 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringSameNames.ts @@ -0,0 +1,29 @@ +// Valid cases + +let { foo, foo: bar } = { foo: 1 }; +({ foo, foo } = { foo: 2 }); +({ foo, foo: bar } = { foo: 3 }); +({ foo: bar, foo } = { foo: 4 }); +({ foo, bar: foo } = { foo: 3, bar: 33 }); +({ bar: foo, foo } = { foo: 4, bar: 44 }); +({ foo: bar, foo: bar } = { foo: 5 }); +({ foo: bar, bar: foo } = { foo: 6, bar: 66 }); +({ foo: bar, foo: bar } = { foo: 7 }); + +[foo, foo] = [111, 1111]; +[foo, foo] = [222, 2222]; +[bar, foo, foo] = [333, 3333, 33333]; +[foo, bar, foo] = [333, 3333, 33333]; +[foo, foo, bar] = [444, 4444, 44444]; + +// Error cases + +let { foo1, foo1 } = { foo1: 10 }; +let { foo2, bar2: foo2 } = { foo2: 20, bar2: 220 }; +let { bar3: foo3, foo3 } = { foo3: 30, bar3: 330 }; +const { foo4, foo4 } = { foo4: 40 }; +const { foo5, bar5: foo5 } = { foo5: 50, bar5: 550 }; +const { bar6: foo6, foo6 } = { foo6: 60, bar6: 660 }; + +let [blah1, blah1] = [111, 222]; +const [blah2, blah2] = [333, 444]; diff --git a/tests/cases/conformance/es6/destructuring/destructuringSamePropertyTwice.ts b/tests/cases/conformance/es6/destructuring/destructuringSamePropertyTwice.ts deleted file mode 100644 index 578f7ac4602..00000000000 --- a/tests/cases/conformance/es6/destructuring/destructuringSamePropertyTwice.ts +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; -let { foo, foo: bar } = { foo: 1 }; -({ foo, foo: bar } = { foo: 2 }); \ No newline at end of file