mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Merge pull request #2643 from Microsoft/checkForOmittedExpression
Check for omitted expressions when checking const and let declaration names
This commit is contained in:
commit
863f0b6180
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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];
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
@ -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];
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user