Use union type when binding element has initializer
This commit is contained in:
parent
f4c621bb8e
commit
88fd3d54b2
1 changed files with 3 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue