diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b87578a26d..881b25ee532 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12596,7 +12596,9 @@ module ts { else { let elements = (name).elements; for (let element of elements) { - checkGrammarNameInLetOrConstDeclarations(element.name); + if (element.kind !== SyntaxKind.OmittedExpression) { + checkGrammarNameInLetOrConstDeclarations(element.name); + } } } } diff --git a/tests/baselines/reference/arrayBindingPatternOmittedExpressions.js b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.js new file mode 100644 index 00000000000..a6f01d7b75c --- /dev/null +++ b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.js @@ -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]; +} diff --git a/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types new file mode 100644 index 00000000000..ba1ac955b85 --- /dev/null +++ b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types @@ -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 +} diff --git a/tests/cases/compiler/arrayBindingPatternOmittedExpressions.ts b/tests/cases/compiler/arrayBindingPatternOmittedExpressions.ts new file mode 100644 index 00000000000..61d8c6f7dda --- /dev/null +++ b/tests/cases/compiler/arrayBindingPatternOmittedExpressions.ts @@ -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]; +} \ No newline at end of file