Exclude typeof this from check in isConstantReference (#52680)

This commit is contained in:
Anders Hejlsberg
2023-02-09 07:06:09 -08:00
committed by GitHub
parent 1c822c42a4
commit 57ebd99ff2
4 changed files with 204 additions and 4 deletions

View File

@@ -26091,10 +26091,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
function isConstantReference(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.Identifier: {
const symbol = getResolvedSymbol(node as Identifier);
return isConstVariable(symbol) || isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol);
}
case SyntaxKind.Identifier:
if (!isThisInTypeQuery(node)) {
const symbol = getResolvedSymbol(node as Identifier);
return isConstVariable(symbol) || isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol);
}
break;
case SyntaxKind.PropertyAccessExpression:
case SyntaxKind.ElementAccessExpression:
// The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here.