From 32aef1a031b0386f2968a8b2636822cd417d730a Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 25 Feb 2015 18:01:40 -0800 Subject: [PATCH] do not report error on non-initialized const bindings in for-in\for-of statements --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7918d393c0b..7094f9e7ea8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11498,7 +11498,8 @@ module ts { if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (isConst(node)) { + // const declarations should not be initialized in for-in for-of statements + if (isConst(node) && node.parent.parent.kind !== SyntaxKind.ForInStatement && node.parent.parent.kind !== SyntaxKind.ForOfStatement) { return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); } }