From 5bb6487bef82e034144c1eba2cbe7be3af3ef7f2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 17 Apr 2020 10:33:28 -0700 Subject: [PATCH] Check for this.xxx access to previously declared uninitialized property --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e6f8f62fe31..47300797cb9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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])