Port #48978 forward to the revised FAR code (#49267)

* Port #48978 forward to the revised FAR code

The old regression test didn't catch the corresponding bug in the new code because it hit the fast path where there's only a single project.

* Drop spurious non-null assertion
This commit is contained in:
Andrew Casey
2022-05-27 09:52:20 -07:00
committed by GitHub
parent 46e53016e4
commit 757a3acbde
5 changed files with 61 additions and 3 deletions

View File

@@ -379,8 +379,8 @@ namespace ts.server {
// have started the other project searches from related symbols. Propagate the
// correct results to all other projects.
const defaultProjectResults = perProjectResults.get(defaultProject)!;
if (defaultProjectResults[0].references[0].isDefinition === undefined) {
const defaultProjectResults = perProjectResults.get(defaultProject);
if (defaultProjectResults?.[0].references[0]?.isDefinition === undefined) {
// Clear all isDefinition properties
perProjectResults.forEach(projectResults => {
for (const referencedSymbol of projectResults) {
@@ -580,7 +580,6 @@ namespace ts.server {
return resultsMap;
// May enqueue to otherPositionQueue
function searchPosition(project: Project, location: DocumentPosition): readonly TResult[] | undefined {
const projectResults = getResultsForPosition(project, location);
if (!projectResults) return undefined;