Fix check in getDiscriminantPropertyAccess (#55464)

This commit is contained in:
Anders Hejlsberg
2023-08-23 11:43:41 -07:00
committed by GitHub
parent 6d07d5fa40
commit fcaa900012
5 changed files with 166 additions and 1 deletions
+1 -1
View File
@@ -27460,7 +27460,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
function getDiscriminantPropertyAccess(expr: Expression, computedType: Type) {
const type = declaredType.flags & TypeFlags.Union ? declaredType : computedType;
const type = !(computedType.flags & TypeFlags.Union) && declaredType.flags & TypeFlags.Union ? declaredType : computedType;
if (type.flags & TypeFlags.Union) {
const access = getCandidateDiscriminantPropertyAccess(expr);
if (access) {