Allow destructuring in ambient context

This commit is contained in:
Yui T
2015-03-19 14:42:57 -07:00
parent 36ea7c8d77
commit b5065f1f3a
3 changed files with 9 additions and 15 deletions

View File

@@ -12005,9 +12005,6 @@ module ts {
function checkGrammarVariableDeclaration(node: VariableDeclaration) {
if (node.parent.parent.kind !== SyntaxKind.ForInStatement && node.parent.parent.kind !== SyntaxKind.ForOfStatement) {
if (isInAmbientContext(node)) {
if (isBindingPattern(node.name)) {
return grammarErrorOnNode(node, Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts);
}
if (node.initializer) {
// Error on equals token which immediate precedes the initializer
let equalsTokenLength = "=".length;

View File

@@ -1,12 +0,0 @@
tests/cases/conformance/es6/destructuring/declarationInAmbientContext.ts(1,13): error TS1183: Destructuring declarations are not allowed in ambient contexts.
tests/cases/conformance/es6/destructuring/declarationInAmbientContext.ts(2,13): error TS1183: Destructuring declarations are not allowed in ambient contexts.
==== tests/cases/conformance/es6/destructuring/declarationInAmbientContext.ts (2 errors) ====
declare var [a, b]; // Error, destructuring declaration not allowed in ambient context
~~~~~~
!!! error TS1183: Destructuring declarations are not allowed in ambient contexts.
declare var {c, d}; // Error, destructuring declaration not allowed in ambient context
~~~~~~
!!! error TS1183: Destructuring declarations are not allowed in ambient contexts.

View File

@@ -0,0 +1,9 @@
=== tests/cases/conformance/es6/destructuring/declarationInAmbientContext.ts ===
declare var [a, b]; // Error, destructuring declaration not allowed in ambient context
>a : any
>b : any
declare var {c, d}; // Error, destructuring declaration not allowed in ambient context
>c : any
>d : any