Removed custom guard and added isArray

This commit is contained in:
Armando Aguirre
2017-10-23 16:03:47 -07:00
parent 16c3255988
commit 051da11113
+6 -9
View File
@@ -641,16 +641,17 @@ namespace FourSlash {
const defs = getDefs();
let definitions: ts.DefinitionInfo[] | ReadonlyArray<ts.DefinitionInfo>;
let testName: string;
if (this.isDefinitionInfoAndBoundSpan(defs)) {
if (!defs || Array.isArray(defs)) {
definitions = defs as ts.DefinitionInfo[] || [];
testName = "goToDefinitions";
}
else {
this.verifyDefinitionTextSpan(defs, startMarkerName);
definitions = defs.definitions;
testName = "goToDefinitionsAndBoundSpan";
}
else {
definitions = defs || [];
testName = "goToDefinitions";
}
if (endMarkers.length !== definitions.length) {
this.raiseError(`${testName} failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`);
@@ -682,10 +683,6 @@ namespace FourSlash {
}
}
private isDefinitionInfoAndBoundSpan(definition: ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined): definition is ts.DefinitionInfoAndBoundSpan {
return definition && (<ts.DefinitionInfoAndBoundSpan>definition).definitions !== undefined;
}
public verifyGetEmitOutputForCurrentFile(expected: string): void {
const emit = this.languageService.getEmitOutput(this.activeFile.fileName);
if (emit.outputFiles.length !== 1) {