diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d63f85de71e..7ad58f4717b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2975,7 +2975,9 @@ namespace ts { if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & TypeFlags.Undefined)) { type = getTypeWithFacts(type, TypeFacts.NEUndefined); } - return type; + return declaration.initializer ? + getUnionType([type, checkExpressionCached(declaration.initializer)], /*subtypeReduction*/ true) : + type; } function getTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration) {