diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c1e401912d..9afa1c1e2c3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2974,7 +2974,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) {