not narrow static property without type annotation in constructor. (#39252)

* fix #39226

* fix lint.
This commit is contained in:
ShuiRuTian
2020-06-27 02:08:35 +08:00
committed by GitHub
parent eb2f4e2337
commit 4601a786aa
6 changed files with 71 additions and 1 deletions

View File

@@ -7825,7 +7825,7 @@ namespace ts {
return addOptionality(type, isOptional);
}
if (isPropertyDeclaration(declaration) && (noImplicitAny || isInJSFile(declaration))) {
if (isPropertyDeclaration(declaration) && !hasStaticModifier(declaration) && (noImplicitAny || isInJSFile(declaration))) {
// We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file.
// Use control flow analysis of this.xxx assignments in the constructor to determine the type of the property.
const constructor = findConstructorDeclaration(declaration.parent);