Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4545,8 +4545,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}

write(";");
tempIndex++;
}
// Regardless of whether we will emit a var declaration for the binding pattern, we generate the temporary
// variable for the parameter (see: emitParameter)
tempIndex++;
}
else if (initializer) {
writeLine();
Expand Down
27 changes: 27 additions & 0 deletions tests/baselines/reference/destructuringParameterDeclaration7ES5.js
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];
}
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))

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

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[]) {}