Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3062,7 +3062,7 @@ namespace ts {
}
return true;
}
else if(jsxContainer) {
else if (jsxContainer) {
let attrsType: Type;
if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) {
// Cursor is inside a JSX self-closing element or opening element
Expand Down Expand Up @@ -3162,7 +3162,7 @@ namespace ts {
switch (previousToken.kind) {
case SyntaxKind.CommaToken:
return containingNodeKind === SyntaxKind.CallExpression // func( a, |
|| containingNodeKind === SyntaxKind.Constructor // constructor( a, | public, protected, private keywords are allowed here, so show completion
|| containingNodeKind === SyntaxKind.Constructor // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
|| containingNodeKind === SyntaxKind.NewExpression // new C(a, |
|| containingNodeKind === SyntaxKind.ArrayLiteralExpression // [a, |
|| containingNodeKind === SyntaxKind.BinaryExpression // let x = (a, |
Expand All @@ -3173,10 +3173,12 @@ namespace ts {
|| containingNodeKind === SyntaxKind.Constructor // constructor( |
|| containingNodeKind === SyntaxKind.NewExpression // new C(a|
|| containingNodeKind === SyntaxKind.ParenthesizedExpression // let x = (a|
|| containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| this can become an arrow function, where 'a' is the argument
|| containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */

case SyntaxKind.OpenBracketToken:
return containingNodeKind === SyntaxKind.ArrayLiteralExpression; // [ |
return containingNodeKind === SyntaxKind.ArrayLiteralExpression // [ |
|| containingNodeKind === SyntaxKind.IndexSignature // [ | : string ]
|| containingNodeKind === SyntaxKind.ComputedPropertyName // [ | /* this can become an index signature */

case SyntaxKind.ModuleKeyword: // module |
case SyntaxKind.NamespaceKeyword: // namespace |
Expand Down
20 changes: 20 additions & 0 deletions tests/cases/fourslash/completionListInIndexSignature01.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// <reference path='fourslash.ts' />

////interface I<T> {
//// [/*1*/]: T;
//// [/*2*/]: T;
////}
////
////class C {
//// [/*3*/]: string;
//// [str/*4*/: string]: number;
////}
////
////type T = {
//// [x/*5*/yz: number]: boolean;
//// [/*6*/

for (let marker of test.markers()) {
goTo.position(marker.position);
verify.completionListAllowsNewIdentifier();
}
19 changes: 19 additions & 0 deletions tests/cases/fourslash/completionListInIndexSignature02.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />

////interface I<T> {
//// [x: /*1*/]: T;
//// [: /*2*/]: T
////}
////
////class C {
//// [a: /*3*/]: string;
//// [str: string/*4*/]: number;
////}
////
////type T = {
//// [xyz: /*5*/

for (let marker of test.markers()) {
goTo.position(marker.position);
verify.not.completionListAllowsNewIdentifier();
}