Check for this.xxx access to previously declared uninitialized property

This commit is contained in:
Anders Hejlsberg
2020-04-17 10:33:28 -07:00
parent 728d9cb911
commit 5bb6487bef

View File

@@ -1366,7 +1366,7 @@ namespace ts {
return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile);
}
if (declaration.pos <= usage.pos) {
if (declaration.pos <= usage.pos && !(isPropertyDeclaration(declaration) && isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) {
// declaration is before usage
if (declaration.kind === SyntaxKind.BindingElement) {
// still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2])