Fix missing reference in js (#50509) (#53000)

This commit is contained in:
gu
2023-03-18 06:51:11 +08:00
committed by GitHub
parent b7b0b52d68
commit bf369f1b95
3 changed files with 246 additions and 1 deletions

View File

@@ -45149,6 +45149,20 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return undefined;
}
function isThisPropertyAndThisTyped(node: PropertyAccessExpression) {
if (node.expression.kind === SyntaxKind.ThisKeyword) {
const container = getThisContainer(node, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false);
if (isFunctionLike(container)) {
const containingLiteral = getContainingObjectLiteral(container);
if (containingLiteral) {
const contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined);
const type = contextualType && getThisTypeFromContextualType(contextualType);
return type && !isTypeAny(type);
}
}
}
}
function getSymbolOfNameOrPropertyAccessExpression(name: EntityName | PrivateIdentifier | PropertyAccessExpression | JSDocMemberName): Symbol | undefined {
if (isDeclarationName(name)) {
return getSymbolOfNode(name.parent);
@@ -45158,7 +45172,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
name.parent.kind === SyntaxKind.PropertyAccessExpression &&
name.parent === (name.parent.parent as BinaryExpression).left) {
// Check if this is a special property assignment
if (!isPrivateIdentifier(name) && !isJSDocMemberName(name)) {
if (!isPrivateIdentifier(name) && !isJSDocMemberName(name) && !isThisPropertyAndThisTyped(name.parent as PropertyAccessExpression)) {
const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
if (specialPropertyAssignmentSymbol) {
return specialPropertyAssignmentSymbol;