Narrow types by satisfies expressions (#60782)

This commit is contained in:
Mateusz Burzyński
2025-01-22 22:44:58 +01:00
committed by GitHub
parent 7f802bbca2
commit efe07a0921
6 changed files with 125 additions and 2 deletions

View File

@@ -27185,7 +27185,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return target.kind === SyntaxKind.SuperKeyword;
case SyntaxKind.NonNullExpression:
case SyntaxKind.ParenthesizedExpression:
return isMatchingReference((source as NonNullExpression | ParenthesizedExpression).expression, target);
case SyntaxKind.SatisfiesExpression:
return isMatchingReference((source as NonNullExpression | ParenthesizedExpression | SatisfiesExpression).expression, target);
case SyntaxKind.PropertyAccessExpression:
case SyntaxKind.ElementAccessExpression:
const sourcePropertyName = getAccessedPropertyName(source as AccessExpression);
@@ -29537,7 +29538,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return narrowTypeByCallExpression(type, expr as CallExpression, assumeTrue);
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.NonNullExpression:
return narrowType(type, (expr as ParenthesizedExpression | NonNullExpression).expression, assumeTrue);
case SyntaxKind.SatisfiesExpression:
return narrowType(type, (expr as ParenthesizedExpression | NonNullExpression | SatisfiesExpression).expression, assumeTrue);
case SyntaxKind.BinaryExpression:
return narrowTypeByBinaryExpression(type, expr as BinaryExpression, assumeTrue);
case SyntaxKind.PrefixUnaryExpression: