Skip to content

Commit ab441f1

Browse files
Apply suggestions from code review
Co-authored-by: Daniel Rosenwasser <[email protected]>
1 parent 1221256 commit ab441f1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/compiler/programDiagnostics.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,15 @@ export function createProgramDiagnostics(getCompilerOptionsObjectLiteralSyntax:
204204

205205
function createDiagnosticExplainingFile(program: Program, file: SourceFile | undefined, fileProcessingReason: FileIncludeReason | undefined, diagnostic: DiagnosticMessage, args: DiagnosticArguments): Diagnostic {
206206
let seenReasons: Set<FileIncludeReason> | undefined;
207-
const reasons = file && fileReasons.get(file.path);
208207
let fileIncludeReasons: DiagnosticMessageChain[] | undefined;
209208
let relatedInfo: DiagnosticWithLocation[] | undefined;
210-
let locationReason = isReferencedFile(fileProcessingReason) ? fileProcessingReason : undefined;
211209
let fileIncludeReasonDetails: DiagnosticMessageChain | undefined;
212210
let redirectInfo: DiagnosticMessageChain[] | undefined;
213-
let cachedChain = file && fileReasonsToChain?.get(file.path);
214211
let chain: DiagnosticMessageChain | undefined;
212+
213+
const reasons = file && fileReasons.get(file.path);
214+
let locationReason = isReferencedFile(fileProcessingReason) ? fileProcessingReason : undefined;
215+
let cachedChain = file && fileReasonsToChain?.get(file.path);
215216
if (cachedChain) {
216217
if (cachedChain.fileIncludeReasonDetails) {
217218
seenReasons = new Set(reasons);
@@ -235,7 +236,7 @@ export function createProgramDiagnostics(getCompilerOptionsObjectLiteralSyntax:
235236

236237
if (seenReasons && cachedChain) {
237238
if (cachedChain.details && !processedExtraReason) {
238-
chain = chainDiagnosticMessages(cachedChain.details, diagnostic, ...args || emptyArray);
239+
chain = chainDiagnosticMessages(cachedChain.details, diagnostic, ...args ?? emptyArray);
239240
}
240241
else if (cachedChain.fileIncludeReasonDetails) {
241242
if (!processedExtraReason) {

0 commit comments

Comments
 (0)