[Release-2.0] Fix 9782: do not report blocked-scope-used-before-declaration error in ambient context (#9789) (#9830)

* Do not report block-scoped-used-before-declaration in ambient context

* Add tests and baselines
This commit is contained in:
Yui
2016-07-19 15:16:27 -07:00
committed by GitHub
parent 2a26beb9d8
commit 80db0f2f16
4 changed files with 23 additions and 1 deletions

View File

@@ -974,7 +974,7 @@ namespace ts {
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
if (!isBlockScopedNameDeclaredBeforeUse(<Declaration>getAncestor(declaration, SyntaxKind.VariableDeclaration), errorLocation)) {
if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(<Declaration>getAncestor(declaration, SyntaxKind.VariableDeclaration), errorLocation)) {
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
}
}