Merge pull request #2643 from Microsoft/checkForOmittedExpression

Check for omitted expressions when checking const and let declaration names
This commit is contained in:
Mohamed Hegazy 2015-04-06 16:42:51 -07:00
commit 863f0b6180
4 changed files with 94 additions and 1 deletions

View File

@ -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);
}
}
}
}

View File

@ -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];
}

View File

@ -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
}

View File

@ -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];
}