print/fwd SWC errors properly

https://github.com/microsoft/vscode/issues/173074
pull/173143/head
Johannes 2023-02-02 11:57:38 +01:00
parent fccbc488ea
commit f7f42dbd63
No known key found for this signature in database
GPG Key ID: 6DEF802A22264FCA
2 changed files with 9 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -40,9 +40,11 @@ export function create(
onError: (message: string) => void = _defaultOnError
): IncrementalCompiler {
function printDiagnostic(diag: ts.Diagnostic): void {
function printDiagnostic(diag: ts.Diagnostic | Error): void {
if (!diag.file || !diag.start) {
if (diag instanceof Error) {
onError(diag.message);
} else if (!diag.file || !diag.start) {
onError(ts.flattenDiagnosticMessageText(diag.messageText, '\n'));
} else {
const lineAndCh = diag.file.getLineAndCharacterOfPosition(diag.start);