Error on this.xxx access of previously declared but uninitialized property (#38030)

* Error on this.xxx access of previously declared but uninitialized property

* Add tests

* Accept new baselines
This commit is contained in:
Anders Hejlsberg
2020-04-28 12:52:14 -07:00
committed by GitHub
parent 9d8a70c809
commit 16d2eb7075
8 changed files with 431 additions and 2 deletions

View File

@@ -1364,7 +1364,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])