Add used-before-declaration errors for class refs inside computed names (#23784)

This commit is contained in:
Wesley Wigham
2018-04-30 12:55:30 -07:00
committed by GitHub
parent 96b2cf8aba
commit 0c244d86b3
7 changed files with 170 additions and 0 deletions

View File

@@ -1111,6 +1111,10 @@ namespace ts {
// still might be illegal if usage is in the initializer of the variable declaration (eg var a = a)
return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration as VariableDeclaration, usage);
}
else if (isClassDeclaration(declaration)) {
// still might be illegal if the usage is within a computed property name in the class (eg class A { static p = "a"; [A.p]() {} })
return !findAncestor(usage, n => isComputedPropertyName(n) && n.parent.parent === declaration);
}
return true;
}