mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Consider all union types matching discriminator for excess property checks (#51884)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
co-authored by
Jake Bailey
parent
3ba3ace236
commit
4fcb8b8be6
@@ -22585,15 +22585,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
if (match === -1) {
|
||||
return defaultValue;
|
||||
}
|
||||
// make sure exactly 1 matches before returning it
|
||||
let nextMatch = discriminable.indexOf(/*searchElement*/ true, match + 1);
|
||||
while (nextMatch !== -1) {
|
||||
if (!isTypeIdenticalTo(target.types[match], target.types[nextMatch])) {
|
||||
return defaultValue;
|
||||
}
|
||||
nextMatch = discriminable.indexOf(/*searchElement*/ true, nextMatch + 1);
|
||||
}
|
||||
return target.types[match];
|
||||
return getUnionType(target.types.filter((_, index) => discriminable[index]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user