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/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12596,7 +12596,9 @@ module ts {
else {
let elements = (<BindingPattern>name).elements;
for (let element of elements) {
checkGrammarNameInLetOrConstDeclarations(element.name);
if (element.kind !== SyntaxKind.OmittedExpression) {
checkGrammarNameInLetOrConstDeclarations(element.name);
}
}
}
}
Expand Down
31 changes: 31 additions & 0 deletions tests/baselines/reference/arrayBindingPatternOmittedExpressions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//// [arrayBindingPatternOmittedExpressions.ts]

var results: string[];

{
let [, b, , a] = results;
let x = {
a,
b
}
}


function f([, a, , b, , , , s, , , ] = results) {
a = s[1];
b = s[2];
}

//// [arrayBindingPatternOmittedExpressions.js]
var results;
{
let [, b, , a] = results;
let x = {
a,
b
};
}
function f([, a, , b, , , , s, , ,] = results) {
a = s[1];
b = s[2];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
=== tests/cases/compiler/arrayBindingPatternOmittedExpressions.ts ===

var results: string[];
>results : string[]

{
let [, b, , a] = results;
>b : string
>a : string
>results : string[]

let x = {
>x : { a: string; b: string; }
>{ a, b } : { a: string; b: string; }

a,
>a : string

b
>b : string
}
}


function f([, a, , b, , , , s, , , ] = results) {
>f : ([, a, , b, , , , s, , , ]?: string[]) => void
>a : string
>b : string
>s : string
>results : string[]

a = s[1];
>a = s[1] : string
>a : string
>s[1] : string
>s : string

b = s[2];
>b = s[2] : string
>b : string
>s[2] : string
>s : string
}
17 changes: 17 additions & 0 deletions tests/cases/compiler/arrayBindingPatternOmittedExpressions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @target: ES6

var results: string[];

{
let [, b, , a] = results;
let x = {
a,
b
}
}


function f([, a, , b, , , , s, , , ] = results) {
a = s[1];
b = s[2];
}