Skip isBlockScopedNameDeclaredBeforeUse error in interface or type declarations

Fixes #35947.
This commit is contained in:
Eli Barzilay
2020-03-27 15:54:34 -04:00
parent dcc6c9461e
commit e4babd40e0
5 changed files with 90 additions and 1 deletions

View File

@@ -1418,7 +1418,7 @@ namespace ts {
return true;
}
if (!!(usage.flags & NodeFlags.JSDoc) || isInTypeQuery(usage)) {
if (!!(usage.flags & NodeFlags.JSDoc) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
return true;
}
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
@@ -1432,6 +1432,10 @@ namespace ts {
}
return false;
function usageInTypeDeclaration() {
return !!findAncestor(usage, node => isInterfaceDeclaration(node) || isTypeAliasDeclaration(node));
}
function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration: VariableDeclaration, usage: Node): boolean {
switch (declaration.parent.parent.kind) {
case SyntaxKind.VariableStatement: