mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 20:25:23 -06:00
Remove 'undefined' from type of binding element with non-undefined default value
This commit is contained in:
parent
4c641c4147
commit
f774ecf4ec
@ -2678,6 +2678,11 @@ namespace ts {
|
||||
type = createArrayType(elementType);
|
||||
}
|
||||
}
|
||||
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
|
||||
// undefined from the final type.
|
||||
if (strictNullChecks && declaration.initializer && !(getNullableKind(checkExpressionCached(declaration.initializer)) & TypeFlags.Undefined)) {
|
||||
type = removeNullableKind(type, TypeFlags.Undefined);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user