We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 598ca48 commit a25104eCopy full SHA for a25104e
src/compiler/checker.ts
@@ -2974,7 +2974,9 @@ namespace ts {
2974
if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & TypeFlags.Undefined)) {
2975
type = getTypeWithFacts(type, TypeFacts.NEUndefined);
2976
}
2977
- return type;
+ return declaration.initializer ?
2978
+ getUnionType([type, checkExpressionCached(declaration.initializer)], /*subtypeReduction*/ true) :
2979
+ type;
2980
2981
2982
function getTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration) {
0 commit comments