From 4315c2a25ff0a4b44523306f98fed8fa8d6e4e85 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 27 Jul 2017 18:11:34 -0700 Subject: [PATCH 1/2] Added failing test case. --- tests/cases/fourslash/codeFixCorrectSpelling4.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/cases/fourslash/codeFixCorrectSpelling4.ts diff --git a/tests/cases/fourslash/codeFixCorrectSpelling4.ts b/tests/cases/fourslash/codeFixCorrectSpelling4.ts new file mode 100644 index 0000000000000..21dd3f03a1d24 --- /dev/null +++ b/tests/cases/fourslash/codeFixCorrectSpelling4.ts @@ -0,0 +1,7 @@ +/// + +//// export declare const despite: { the: any }; +//// +//// [|dispite.the|] + +verify.rangeAfterCodeFix(`despite.the`); From afdbf00d53a112566625555de0621962c38113be Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 27 Jul 2017 18:12:20 -0700 Subject: [PATCH 2/2] Add check to ensure that property access suggestions are only performed on the accessed property. --- src/services/codefixes/fixSpelling.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index c8f539e8d347e..ff3bd455291e2 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -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); }