From 612003d7ee129db83c28aa457ce3fc6ef8b826dc Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 5 Oct 2016 14:19:38 -0700 Subject: [PATCH] Fix incorrect returning of completion entries when in string literal of property assignment expression Fixes #11232 --- src/services/completions.ts | 4 +++- ...letionListInObjectLiteralPropertyAssignment.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/completionListInObjectLiteralPropertyAssignment.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 64ea05e4f2b..705a3c497c5 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -138,7 +138,9 @@ namespace ts.Completions { return undefined; } - if (node.parent.kind === SyntaxKind.PropertyAssignment && node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression) { + if (node.parent.kind === SyntaxKind.PropertyAssignment && + node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression && + (node.parent).name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { // 'jspm:dev': string diff --git a/tests/cases/fourslash/completionListInObjectLiteralPropertyAssignment.ts b/tests/cases/fourslash/completionListInObjectLiteralPropertyAssignment.ts new file mode 100644 index 00000000000..14ccd985577 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectLiteralPropertyAssignment.ts @@ -0,0 +1,15 @@ +/// + +////var foo; +////interface I { +//// metadata: string; +//// wat: string; +////} +////var x: I = { +//// metadata: "/*1*/ +////} + +goTo.marker('1'); + +verify.not.completionListContains("metadata"); +verify.not.completionListContains("wat"); \ No newline at end of file