Skip to content

Commit 2c47436

Browse files
committed
fix: Resolve NPE
1 parent 424fe49 commit 2c47436

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/typescript.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ export async function run(fileNames: string[], options: ts.CompilerOptions): Pro
8181
allDiagnostics.forEach(diagnostic => {
8282
if (!diagnostic.file) {
8383
console.log(diagnostic)
84+
} else {
85+
const {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start)
86+
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n')
87+
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`)
8488
}
85-
const {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start)
86-
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n')
87-
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`)
8889
})
8990

9091
if (emitResult.emitSkipped) {

0 commit comments

Comments
 (0)