mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Use union type when binding element has initializer
This commit is contained in:
1 parent
598ca48c94
commit
a25104e152
1 file changed
+3
-1
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user