fix(35944): show spell checking quick fix for non-existent private named property access (#36195)

This commit is contained in:
Alexander T
2020-01-16 02:56:40 +02:00
committed by Nathan Shively-Sanders
parent f99072593d
commit dbd55b3928
3 changed files with 21 additions and 3 deletions

View File

@@ -36,12 +36,13 @@ namespace ts.codefix {
let suggestion: string | undefined;
if (isPropertyAccessExpression(node.parent) && node.parent.name === node) {
Debug.assert(node.kind === SyntaxKind.Identifier, "Expected an identifier for spelling (property access)");
Debug.assert(isIdentifierOrPrivateIdentifier(node), "Expected an identifier for spelling (property access)");
let containingType = checker.getTypeAtLocation(node.parent.expression);
if (node.parent.flags & NodeFlags.OptionalChain) {
containingType = checker.getNonNullableType(containingType);
}
suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType);
const name = node as Identifier | PrivateIdentifier;
suggestion = checker.getSuggestionForNonexistentProperty(name, containingType);
}
else if (isImportSpecifier(node.parent) && node.parent.name === node) {
Debug.assert(node.kind === SyntaxKind.Identifier, "Expected an identifier for spelling (import)");