mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
Filter the type of a binding pattern to not include undefined is the pattern parent has an initializer (#37309)
This commit is contained in:
@@ -7164,6 +7164,10 @@ namespace ts {
|
||||
if (strictNullChecks && declaration.flags & NodeFlags.Ambient && isParameterDeclaration(declaration)) {
|
||||
parentType = getNonNullableType(parentType);
|
||||
}
|
||||
// Filter `undefined` from the type we check against if the parent has an initializer (which handles the `undefined` case implicitly)
|
||||
else if (strictNullChecks && pattern.parent.initializer) {
|
||||
parentType = getTypeWithFacts(parentType, TypeFacts.NEUndefined);
|
||||
}
|
||||
|
||||
let type: Type | undefined;
|
||||
if (pattern.kind === SyntaxKind.ObjectBindingPattern) {
|
||||
|
||||
Reference in New Issue
Block a user