Test for isNewIdentifierLocation, and make true for type with index signature (#22910)

This commit is contained in:
Andy
2018-03-27 13:05:41 -07:00
committed by GitHub
parent ccd6a010e0
commit 21cd68dd04
19 changed files with 35 additions and 32 deletions

View File

@@ -840,8 +840,8 @@ namespace FourSlash {
this.raiseError(`No completions at position '${this.currentCaretPosition}'.`);
}
if (options && options.isNewIdentifierLocation !== undefined && actualCompletions.isNewIdentifierLocation !== options.isNewIdentifierLocation) {
this.raiseError(`Expected 'isNewIdentifierLocation' to be ${options.isNewIdentifierLocation}, got ${actualCompletions.isNewIdentifierLocation}`);
if (actualCompletions.isNewIdentifierLocation !== (options && options.isNewIdentifierLocation || false)) {
this.raiseError(`Expected 'isNewIdentifierLocation' to be ${options && options.isNewIdentifierLocation}, got ${actualCompletions.isNewIdentifierLocation}`);
}
const actual = actualCompletions.entries;

View File

@@ -1031,6 +1031,8 @@ namespace ts.Completions {
}
function addTypeProperties(type: Type): void {
isNewIdentifierLocation = !!type.getStringIndexType() || !!type.getNumberIndexType();
if (isSourceFileJavaScript(sourceFile)) {
// In javascript files, for union types, we don't just get the members that
// the individual types have in common, we also include all the members that