Skip to content

Commit 6d83df4

Browse files
committed
Harden combineProjectOutputForReferences against empty results
Getting an empty result doesn't seem expected, but a deeper fix doesn't make sense until microsoft#48619 is merged. Fixes microsoft#48963
1 parent 745e922 commit 6d83df4

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
@@ -354,7 +354,7 @@ namespace ts.server {
354354
logger.info(`Finding references to ${location.fileName} position ${location.pos} in project ${project.getProjectName()}`);
355355
const projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos);
356356
if (projectOutputs) {
357-
const clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined;
357+
const clearIsDefinition = projectOutputs[0]?.references[0]?.isDefinition === undefined;
358358
for (const referencedSymbol of projectOutputs) {
359359
const mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition));
360360
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)