fix(34621): show suggestions in class property initializer (#35999)

This commit is contained in:
Alexander T
2020-01-18 00:27:12 +02:00
committed by Daniel Rosenwasser
parent 94e8db7e07
commit afa11d3c7a
2 changed files with 32 additions and 0 deletions

View File

@@ -2608,6 +2608,9 @@ namespace ts.Completions {
if (!contextToken) return undefined;
switch (contextToken.kind) {
case SyntaxKind.EqualsToken: // class c { public prop = | /* global completions */ }
return undefined;
case SyntaxKind.SemicolonToken: // class c {getValue(): number; | }
case SyntaxKind.CloseBraceToken: // class c { method() { } | }
// class c { method() { } b| }

View File

@@ -0,0 +1,29 @@
/// <reference path='fourslash.ts'/>
////class Class1 {
//// protected a = /*1*/
//// private b = /*2*/
//// public c = /*3*/
//// public d = this./*4*/
////}
////
////class Class2 {
//// a = /*5*/
////}
////class Class3 {
//// a = /*6*/
////}
////
////const prop = 'prop';
////class Class4 {
//// [prop] = /*7*/
////}
const exact = completion.globalsPlus(["Class1", "Class2", "Class3", "prop", "Class4"]);
verify.completions({ marker: ["1"], exact });
verify.completions({ marker: ["2"], exact });
verify.completions({ marker: ["3"], exact });
verify.completions({ marker: ["4"], exact: ['a', 'b', 'c', 'd'], isGlobalCompletion: false });
verify.completions({ marker: ["5"], exact });
verify.completions({ marker: ["6"], exact });
verify.completions({ marker: ["7"], exact });