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); } }