Don't consider x. a new identifier location just because x has a number index signature (#24699)

* Don't consider `x.` a new identifier location just because x has a number index signature

* Update more tests
This commit is contained in:
Andy
2018-06-07 12:05:47 -07:00
committed by GitHub
parent d0ae03c4cc
commit 83c58a4fb5
4 changed files with 10 additions and 6 deletions

View File

@@ -1074,7 +1074,7 @@ namespace ts.Completions {
}
function addTypeProperties(type: Type): void {
isNewIdentifierLocation = hasIndexSignature(type);
isNewIdentifierLocation = !!type.getStringIndexType();
if (isUncheckedFile) {
// In javascript files, for union types, we don't just get the members that

View File

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

View File

@@ -24,7 +24,7 @@
////var test1 = function(x) { return x./*4*/ }, test2 = function(a) { return a./*5*/ };
verify.completions(
{ marker: "1", includes: { name: "charCodeAt", kind: "method" }, isNewIdentifierLocation: true },
{ marker: "1", includes: { name: "charCodeAt", kind: "method" } },
{ marker: ["2", "3", "4"], includes: { name: "toExponential", kind: "method" } },
{ marker: "5", includes: { name: "test1", kind: "warning" } },
);

View File

@@ -22,7 +22,7 @@ edit.insert('.');
verify.completions({ exact: ["bar", "thing", "union", "Foo", "x"] });
edit.insert('bar.');
verify.completions({ includes: ["substr"], isNewIdentifierLocation: true });
verify.completions({ includes: ["substr"] });
edit.backspace('bar.'.length);
edit.insert('union.');