-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 9363: Object destructuring broken-variables are bound to the wron…
…g object (#9383) * Fix emit incorrect destructuring mapping in var declaration * Add tests and baselines * Add additional tests and baselines
- Loading branch information
Showing
5 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/destructuringParameterDeclaration7ES5.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//// [destructuringParameterDeclaration7ES5.ts] | ||
|
||
interface ISomething { | ||
foo: string, | ||
bar: string | ||
} | ||
|
||
function foo({}, {foo, bar}: ISomething) {} | ||
|
||
function baz([], {foo, bar}: ISomething) {} | ||
|
||
function one([], {}) {} | ||
|
||
function two([], [a, b, c]: number[]) {} | ||
|
||
|
||
//// [destructuringParameterDeclaration7ES5.js] | ||
function foo(_a, _b) { | ||
var foo = _b.foo, bar = _b.bar; | ||
} | ||
function baz(_a, _b) { | ||
var foo = _b.foo, bar = _b.bar; | ||
} | ||
function one(_a, _b) { } | ||
function two(_a, _b) { | ||
var a = _b[0], b = _b[1], c = _b[2]; | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/destructuringParameterDeclaration7ES5.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts === | ||
|
||
interface ISomething { | ||
>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0)) | ||
|
||
foo: string, | ||
>foo : Symbol(ISomething.foo, Decl(destructuringParameterDeclaration7ES5.ts, 1, 22)) | ||
|
||
bar: string | ||
>bar : Symbol(ISomething.bar, Decl(destructuringParameterDeclaration7ES5.ts, 2, 16)) | ||
} | ||
|
||
function foo({}, {foo, bar}: ISomething) {} | ||
>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 4, 1)) | ||
>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 6, 18)) | ||
>bar : Symbol(bar, Decl(destructuringParameterDeclaration7ES5.ts, 6, 22)) | ||
>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0)) | ||
|
||
function baz([], {foo, bar}: ISomething) {} | ||
>baz : Symbol(baz, Decl(destructuringParameterDeclaration7ES5.ts, 6, 43)) | ||
>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5.ts, 8, 18)) | ||
>bar : Symbol(bar, Decl(destructuringParameterDeclaration7ES5.ts, 8, 22)) | ||
>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5.ts, 0, 0)) | ||
|
||
function one([], {}) {} | ||
>one : Symbol(one, Decl(destructuringParameterDeclaration7ES5.ts, 8, 43)) | ||
|
||
function two([], [a, b, c]: number[]) {} | ||
>two : Symbol(two, Decl(destructuringParameterDeclaration7ES5.ts, 10, 23)) | ||
>a : Symbol(a, Decl(destructuringParameterDeclaration7ES5.ts, 12, 18)) | ||
>b : Symbol(b, Decl(destructuringParameterDeclaration7ES5.ts, 12, 20)) | ||
>c : Symbol(c, Decl(destructuringParameterDeclaration7ES5.ts, 12, 23)) | ||
|
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/destructuringParameterDeclaration7ES5.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts === | ||
|
||
interface ISomething { | ||
>ISomething : ISomething | ||
|
||
foo: string, | ||
>foo : string | ||
|
||
bar: string | ||
>bar : string | ||
} | ||
|
||
function foo({}, {foo, bar}: ISomething) {} | ||
>foo : ({}: {}, {foo, bar}: ISomething) => void | ||
>foo : string | ||
>bar : string | ||
>ISomething : ISomething | ||
|
||
function baz([], {foo, bar}: ISomething) {} | ||
>baz : ([]: any[], {foo, bar}: ISomething) => void | ||
>foo : string | ||
>bar : string | ||
>ISomething : ISomething | ||
|
||
function one([], {}) {} | ||
>one : ([]: any[], {}: {}) => void | ||
|
||
function two([], [a, b, c]: number[]) {} | ||
>two : ([]: any[], [a, b, c]: number[]) => void | ||
>a : number | ||
>b : number | ||
>c : number | ||
|
14 changes: 14 additions & 0 deletions
14
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// @target: es5 | ||
|
||
interface ISomething { | ||
foo: string, | ||
bar: string | ||
} | ||
|
||
function foo({}, {foo, bar}: ISomething) {} | ||
|
||
function baz([], {foo, bar}: ISomething) {} | ||
|
||
function one([], {}) {} | ||
|
||
function two([], [a, b, c]: number[]) {} |