mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
do not report error on non-initialized const bindings in for-in\for-of statements
This commit is contained in:
1 parent
33dfe5068a
commit
32aef1a031
1 file changed
+2
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user