Skip to content

Commit cd64f2b

Browse files
Merge pull request microsoft#3717 from Microsoft/builderInIndexSignature
Show builder at beginning of index signatures & computed properties
2 parents f37a7f5 + 7abe8a1 commit cd64f2b

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

src/services/services.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -3062,7 +3062,7 @@ namespace ts {
30623062
}
30633063
return true;
30643064
}
3065-
else if(jsxContainer) {
3065+
else if (jsxContainer) {
30663066
let attrsType: Type;
30673067
if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) {
30683068
// Cursor is inside a JSX self-closing element or opening element
@@ -3162,7 +3162,7 @@ namespace ts {
31623162
switch (previousToken.kind) {
31633163
case SyntaxKind.CommaToken:
31643164
return containingNodeKind === SyntaxKind.CallExpression // func( a, |
3165-
|| containingNodeKind === SyntaxKind.Constructor // constructor( a, | public, protected, private keywords are allowed here, so show completion
3165+
|| containingNodeKind === SyntaxKind.Constructor // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
31663166
|| containingNodeKind === SyntaxKind.NewExpression // new C(a, |
31673167
|| containingNodeKind === SyntaxKind.ArrayLiteralExpression // [a, |
31683168
|| containingNodeKind === SyntaxKind.BinaryExpression // let x = (a, |
@@ -3173,10 +3173,12 @@ namespace ts {
31733173
|| containingNodeKind === SyntaxKind.Constructor // constructor( |
31743174
|| containingNodeKind === SyntaxKind.NewExpression // new C(a|
31753175
|| containingNodeKind === SyntaxKind.ParenthesizedExpression // let x = (a|
3176-
|| containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| this can become an arrow function, where 'a' is the argument
3176+
|| containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */
31773177

31783178
case SyntaxKind.OpenBracketToken:
3179-
return containingNodeKind === SyntaxKind.ArrayLiteralExpression; // [ |
3179+
return containingNodeKind === SyntaxKind.ArrayLiteralExpression // [ |
3180+
|| containingNodeKind === SyntaxKind.IndexSignature // [ | : string ]
3181+
|| containingNodeKind === SyntaxKind.ComputedPropertyName // [ | /* this can become an index signature */
31803182

31813183
case SyntaxKind.ModuleKeyword: // module |
31823184
case SyntaxKind.NamespaceKeyword: // namespace |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////interface I<T> {
4+
//// [/*1*/]: T;
5+
//// [/*2*/]: T;
6+
////}
7+
////
8+
////class C {
9+
//// [/*3*/]: string;
10+
//// [str/*4*/: string]: number;
11+
////}
12+
////
13+
////type T = {
14+
//// [x/*5*/yz: number]: boolean;
15+
//// [/*6*/
16+
17+
for (let marker of test.markers()) {
18+
goTo.position(marker.position);
19+
verify.completionListAllowsNewIdentifier();
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////interface I<T> {
4+
//// [x: /*1*/]: T;
5+
//// [: /*2*/]: T
6+
////}
7+
////
8+
////class C {
9+
//// [a: /*3*/]: string;
10+
//// [str: string/*4*/]: number;
11+
////}
12+
////
13+
////type T = {
14+
//// [xyz: /*5*/
15+
16+
for (let marker of test.markers()) {
17+
goTo.position(marker.position);
18+
verify.not.completionListAllowsNewIdentifier();
19+
}

0 commit comments

Comments
 (0)