mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 13:45:34 -05:00
Allow destructuring in ambient context
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user