Harden combineProjectOutputForReferences against empty results (#48978)

Getting an empty result doesn't seem expected, but a deeper fix doesn't make sense until #48619 is merged.

Fixes #48963
This commit is contained in:
Andrew Casey 2022-05-05 13:52:34 -07:00 committed by GitHub
parent 4680b54616
commit 58114cf387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -356,7 +356,7 @@ namespace ts.server {
logger.info(`Finding references to ${location.fileName} position ${location.pos} in project ${project.getProjectName()}`);
const projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos);
if (projectOutputs) {
const clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined;
const clearIsDefinition = projectOutputs[0]?.references[0]?.isDefinition === undefined;
for (const referencedSymbol of projectOutputs) {
const mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition));
const definition: ReferencedSymbolDefinitionInfo = mappedDefinitionFile === undefined ?

View File

@ -0,0 +1,5 @@
/// <reference path="../fourslash.ts"/>
////const str: string = "hello/*1*/";
verify.baselineFindAllReferences('1')