From b4a2aa8d85ddabc238ffddf4205f5ea5b36f71ad Mon Sep 17 00:00:00 2001 From: Menno <1247698+MennoTammens@users.noreply.github.com> Date: Mon, 6 Oct 2025 09:58:33 +0200 Subject: [PATCH] Don't try to access properties of undefined diagnostic file object --- src/typescript.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/typescript.ts b/src/typescript.ts index fd60a798..783277ff 100644 --- a/src/typescript.ts +++ b/src/typescript.ts @@ -81,10 +81,11 @@ export async function run(fileNames: string[], options: ts.CompilerOptions): Pro allDiagnostics.forEach(diagnostic => { if (!diagnostic.file) { console.log(diagnostic) + } else { + const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) + const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n') + console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`) } - const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) - const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n') - console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`) }) if (emitResult.emitSkipped) { @@ -169,4 +170,4 @@ export function getTypescriptCompileFiles( return configParseResult.fileNames.map(f => f.replace(cwd + '/', '')) } return [] -} \ No newline at end of file +}