mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Remove 'undefined' from type of binding element with non-undefined default value
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user