Skip to content

Commit 58114cf

Browse files
authored
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
1 parent 4680b54 commit 58114cf

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/server/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ namespace ts.server {
356356
logger.info(`Finding references to ${location.fileName} position ${location.pos} in project ${project.getProjectName()}`);
357357
const projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos);
358358
if (projectOutputs) {
359-
const clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined;
359+
const clearIsDefinition = projectOutputs[0]?.references[0]?.isDefinition === undefined;
360360
for (const referencedSymbol of projectOutputs) {
361361
const mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition));
362362
const definition: ReferencedSymbolDefinitionInfo = mappedDefinitionFile === undefined ?
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference path="../fourslash.ts"/>
2+
3+
////const str: string = "hello/*1*/";
4+
5+
verify.baselineFindAllReferences('1')

0 commit comments

Comments
 (0)