Skip to content

Commit

Permalink
refactor(diagnostics): simplify some conditionals (#402)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
agilgur5 committed Aug 8, 2022
1 parent bbed47e commit c37dbf6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/print-diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`);
});
}

0 comments on commit c37dbf6

Please sign in to comment.