refactor(diagnostics): simplify some conditionals (#402)

- reduce the complexity of the code by decreasing the amount of nesting

- note that `print` returns `void` anyway, so calling it within the `return` statement doesn't change anything
  - and this is within a `void` `forEach` at that too
This commit is contained in:
Anton Gilgur 2022-08-08 15:22:02 -04:00 committed by GitHub
parent bbed47e16a
commit c37dbf6ee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,13 +34,11 @@ export function printDiagnostics(context: IContext, diagnostics: IDiagnostics[],
const type = diagnostic.type + " ";
if (pretty)
print.call(context, `${diagnostic.formatted}`);
else
{
if (diagnostic.fileLine !== undefined)
print.call(context, `${diagnostic.fileLine}: ${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
else
print.call(context, `${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
}
return print.call(context, `${diagnostic.formatted}`);
if (diagnostic.fileLine !== undefined)
return print.call(context, `${diagnostic.fileLine}: ${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
return print.call(context, `${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
});
}