mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix(52212): No member completions, and irrelevant value completions, when class property initializer has no semicolon (#52213)
This commit is contained in:
@@ -4829,7 +4829,7 @@ function tryGetObjectTypeDeclarationCompletionContainer(sourceFile: SourceFile,
|
||||
return cls;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.Identifier: {
|
||||
case SyntaxKind.Identifier: {
|
||||
const originalKeywordKind = identifierToKeywordKind(location as Identifier);
|
||||
if (originalKeywordKind) {
|
||||
return undefined;
|
||||
@@ -4868,16 +4868,17 @@ function tryGetObjectTypeDeclarationCompletionContainer(sourceFile: SourceFile,
|
||||
case SyntaxKind.CommaToken: // class c {getValue(): number, | }
|
||||
return tryCast(contextToken.parent, isObjectTypeDeclaration);
|
||||
default:
|
||||
if (!isFromObjectTypeDeclaration(contextToken)) {
|
||||
// class c extends React.Component { a: () => 1\n| }
|
||||
if (getLineAndCharacterOfPosition(sourceFile, contextToken.getEnd()).line !== getLineAndCharacterOfPosition(sourceFile, position).line && isObjectTypeDeclaration(location)) {
|
||||
if (isObjectTypeDeclaration(location)) {
|
||||
// class C extends React.Component { a: () => 1\n| }
|
||||
// class C { prop = ""\n | }
|
||||
if (getLineAndCharacterOfPosition(sourceFile, contextToken.getEnd()).line !== getLineAndCharacterOfPosition(sourceFile, position).line) {
|
||||
return location;
|
||||
}
|
||||
return undefined;
|
||||
const isValidKeyword = isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword;
|
||||
return (isValidKeyword(contextToken.kind) || contextToken.kind === SyntaxKind.AsteriskToken || isIdentifier(contextToken) && isValidKeyword(identifierToKeywordKind(contextToken) ?? SyntaxKind.Unknown))
|
||||
? contextToken.parent.parent as ObjectTypeDeclaration : undefined;
|
||||
}
|
||||
const isValidKeyword = isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword;
|
||||
return (isValidKeyword(contextToken.kind) || contextToken.kind === SyntaxKind.AsteriskToken || isIdentifier(contextToken) && isValidKeyword(identifierToKeywordKind(contextToken) ?? SyntaxKind.Unknown))
|
||||
? contextToken.parent.parent as ObjectTypeDeclaration : undefined;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user