Skip to content

Commit b5065f1

Browse files
author
Yui T
committed
Allow destructuring in ambient context
1 parent 36ea7c8 commit b5065f1

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/compiler/checker.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12005,9 +12005,6 @@ module ts {
1200512005
function checkGrammarVariableDeclaration(node: VariableDeclaration) {
1200612006
if (node.parent.parent.kind !== SyntaxKind.ForInStatement && node.parent.parent.kind !== SyntaxKind.ForOfStatement) {
1200712007
if (isInAmbientContext(node)) {
12008-
if (isBindingPattern(node.name)) {
12009-
return grammarErrorOnNode(node, Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts);
12010-
}
1201112008
if (node.initializer) {
1201212009
// Error on equals token which immediate precedes the initializer
1201312010
let equalsTokenLength = "=".length;

tests/baselines/reference/declarationInAmbientContext.errors.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/es6/destructuring/declarationInAmbientContext.ts ===
2+
declare var [a, b]; // Error, destructuring declaration not allowed in ambient context
3+
>a : any
4+
>b : any
5+
6+
declare var {c, d}; // Error, destructuring declaration not allowed in ambient context
7+
>c : any
8+
>d : any
9+

0 commit comments

Comments
 (0)