diff --git a/src/services/services.ts b/src/services/services.ts index edb7032b810..4458a45ed04 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3573,14 +3573,16 @@ module ts { function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] { let results = getOccurrencesAtPositionCore(fileName, position); + + if (results) { + let sourceFile = getCanonicalFileName(normalizeSlashes(fileName)); - let sourceFile = getCanonicalFileName(normalizeSlashes(fileName)); - - // ensure the results are in the file we're interested in - results.forEach((value) => { - let targetFile = getCanonicalFileName(normalizeSlashes(value.fileName)); - Debug.assert(sourceFile == targetFile, `Unexpected file in results. Found results in ${targetFile} expected only results in ${sourceFile}.`); - }); + // ensure the results are in the file we're interested in + results.forEach((value) => { + let targetFile = getCanonicalFileName(normalizeSlashes(value.fileName)); + Debug.assert(sourceFile == targetFile, `Unexpected file in results. Found results in ${targetFile} expected only results in ${sourceFile}.`); + }); + } return results; }