Skip to content

Commit 83c58a4

Browse files
author
Andy
authored
Don't consider x. a new identifier location just because x has a number index signature (microsoft#24699)
* Don't consider `x.` a new identifier location just because x has a number index signature * Update more tests
1 parent d0ae03c commit 83c58a4

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/services/completions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ namespace ts.Completions {
10741074
}
10751075

10761076
function addTypeProperties(type: Type): void {
1077-
isNewIdentifierLocation = hasIndexSignature(type);
1077+
isNewIdentifierLocation = !!type.getStringIndexType();
10781078

10791079
if (isUncheckedFile) {
10801080
// In javascript files, for union types, we don't just get the members that

tests/cases/fourslash/completionListAfterStringLiteral1.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
////"a"./**/
44

5-
goTo.marker();
6-
verify.not.completionListContains('alert');
7-
verify.completionListContains('charAt');
5+
verify.completions({
6+
marker: "",
7+
exact: [
8+
"toString", "charAt", "charCodeAt", "concat", "indexOf", "lastIndexOf", "localeCompare", "match", "replace", "search", "slice",
9+
"split", "substring", "toLowerCase", "toLocaleLowerCase", "toUpperCase", "toLocaleUpperCase", "trim", "length", "substr", "valueOf",
10+
],
11+
});

tests/cases/fourslash/getJavaScriptCompletions12.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
////var test1 = function(x) { return x./*4*/ }, test2 = function(a) { return a./*5*/ };
2525

2626
verify.completions(
27-
{ marker: "1", includes: { name: "charCodeAt", kind: "method" }, isNewIdentifierLocation: true },
27+
{ marker: "1", includes: { name: "charCodeAt", kind: "method" } },
2828
{ marker: ["2", "3", "4"], includes: { name: "toExponential", kind: "method" } },
2929
{ marker: "5", includes: { name: "test1", kind: "warning" } },
3030
);

tests/cases/fourslash/javaScriptClass1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ edit.insert('.');
2222
verify.completions({ exact: ["bar", "thing", "union", "Foo", "x"] });
2323

2424
edit.insert('bar.');
25-
verify.completions({ includes: ["substr"], isNewIdentifierLocation: true });
25+
verify.completions({ includes: ["substr"] });
2626
edit.backspace('bar.'.length);
2727

2828
edit.insert('union.');

0 commit comments

Comments
 (0)