Skip to content

Commit 4bf42fd

Browse files
authored
Merge pull request #25535 from Microsoft/fixAsserts
Fix assert and check for module symbol
2 parents c344a3e + 2c70030 commit 4bf42fd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/services/findAllReferences.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ namespace ts.FindAllReferences.Core {
234234
export function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray<SourceFile>, cancellationToken: CancellationToken, options: Options = {}, sourceFilesSet: ReadonlyMap<true> = arrayToSet(sourceFiles, f => f.fileName)): SymbolAndEntries[] | undefined {
235235
if (isSourceFile(node)) {
236236
const reference = GoToDefinition.getReferenceAtPosition(node, position, program);
237-
return reference && getReferencedSymbolsForModule(program, program.getTypeChecker().getMergedSymbol(reference.file.symbol), /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet);
237+
const moduleSymbol = reference && program.getTypeChecker().getMergedSymbol(reference.file.symbol);
238+
return moduleSymbol && getReferencedSymbolsForModule(program, moduleSymbol, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet);
238239
}
239240

240241
if (!options.implementations) {

src/services/services.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,8 @@ namespace ts {
15371537
}
15381538

15391539
function getDocumentHighlights(fileName: string, position: number, filesToSearch: ReadonlyArray<string>): DocumentHighlights[] | undefined {
1540-
Debug.assert(filesToSearch.some(f => normalizePath(f) === fileName));
1540+
const normalizedFileName = normalizePath(fileName);
1541+
Debug.assert(filesToSearch.some(f => normalizePath(f) === normalizedFileName));
15411542
synchronizeHostData();
15421543
const sourceFilesToSearch = map(filesToSearch, f => Debug.assertDefined(program.getSourceFile(f)));
15431544
const sourceFile = getValidSourceFile(fileName);

0 commit comments

Comments
 (0)