Merge pull request #17474 from Microsoft/quickFixLeftOfPropertyAccess

Enable spelling quick fixes for left side of property access
This commit is contained in:
Daniel Rosenwasser 2017-07-27 18:33:11 -07:00 committed by GitHub
commit 74e4903753
2 changed files with 9 additions and 1 deletions

View file

@ -15,7 +15,8 @@ namespace ts.codefix {
const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); // TODO: GH#15852
const checker = context.program.getTypeChecker();
let suggestion: string;
if (node.kind === SyntaxKind.Identifier && isPropertyAccessExpression(node.parent)) {
if (isPropertyAccessExpression(node.parent) && node.parent.name === node) {
Debug.assert(node.kind === SyntaxKind.Identifier);
const containingType = checker.getTypeAtLocation(node.parent.expression);
suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType);
}

View file

@ -0,0 +1,7 @@
/// <reference path='fourslash.ts' />
//// export declare const despite: { the: any };
////
//// [|dispite.the|]
verify.rangeAfterCodeFix(`despite.the`);