From a5fbbddbd74b8c58cc600e3f3f8985cd8cecb13a Mon Sep 17 00:00:00 2001 From: arusakov Date: Sun, 23 Oct 2016 23:39:44 +0300 Subject: [PATCH 1/2] Fix #10108 (Completion suggestion for object literal with getter) --- src/services/completions.ts | 3 ++- tests/cases/fourslash/server/completions03.ts | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/server/completions03.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index ba5d150307519..9bd735f773ddd 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1590,7 +1590,8 @@ namespace ts.Completions { if (m.kind !== SyntaxKind.PropertyAssignment && m.kind !== SyntaxKind.ShorthandPropertyAssignment && m.kind !== SyntaxKind.BindingElement && - m.kind !== SyntaxKind.MethodDeclaration) { + m.kind !== SyntaxKind.MethodDeclaration && + m.kind !== SyntaxKind.GetAccessor) { continue; } diff --git a/tests/cases/fourslash/server/completions03.ts b/tests/cases/fourslash/server/completions03.ts new file mode 100644 index 0000000000000..da8c75f3c6f56 --- /dev/null +++ b/tests/cases/fourslash/server/completions03.ts @@ -0,0 +1,17 @@ +/// + +// issue: https://github.com/Microsoft/TypeScript/issues/10108 + +//// interface Foo { +//// one: any; +//// two: any; +//// } +//// +//// let x: Foo = { +//// get one() { return "" }, +//// /**/ +//// } + +goTo.marker(""); +verify.completionListContains("two"); +verify.not.completionListContains("one"); From 093604afc84aaf1d84c57f6ee0ac7cb722cda1be Mon Sep 17 00:00:00 2001 From: arusakov Date: Tue, 25 Oct 2016 23:03:40 +0300 Subject: [PATCH 2/2] completions for setter --- src/services/completions.ts | 3 ++- tests/cases/fourslash/server/completions03.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index 9bd735f773ddd..b710aa8cd78bb 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1591,7 +1591,8 @@ namespace ts.Completions { m.kind !== SyntaxKind.ShorthandPropertyAssignment && m.kind !== SyntaxKind.BindingElement && m.kind !== SyntaxKind.MethodDeclaration && - m.kind !== SyntaxKind.GetAccessor) { + m.kind !== SyntaxKind.GetAccessor && + m.kind !== SyntaxKind.SetAccessor) { continue; } diff --git a/tests/cases/fourslash/server/completions03.ts b/tests/cases/fourslash/server/completions03.ts index da8c75f3c6f56..ef5f165195126 100644 --- a/tests/cases/fourslash/server/completions03.ts +++ b/tests/cases/fourslash/server/completions03.ts @@ -5,13 +5,16 @@ //// interface Foo { //// one: any; //// two: any; +//// three: any; //// } //// //// let x: Foo = { //// get one() { return "" }, +//// set two(t) {}, //// /**/ //// } goTo.marker(""); -verify.completionListContains("two"); +verify.completionListContains("three"); verify.not.completionListContains("one"); +verify.not.completionListContains("two");