Add Support for Using Aliased Discriminants in Conditional Statements (#56173)

This commit is contained in:
Zzzen
2023-11-08 15:06:40 -08:00
committed by GitHub
parent 50f48840a3
commit 7b96c28e8f
6 changed files with 1126 additions and 0 deletions
+4
View File
@@ -27244,6 +27244,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
case SyntaxKind.ElementAccessExpression:
// The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here.
return isConstantReference((node as AccessExpression).expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol);
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.ArrayBindingPattern:
const rootDeclaration = getRootDeclaration(node.parent);
return isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
}
return false;
}