Skip to content

Commit f531453

Browse files
clydinhansl
authored andcommitted
refactor(@angular-devkit/build-optimizer): correct implicit returns
1 parent 80b94ad commit f531453

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

packages/angular_devkit/build_optimizer/src/helpers/transform-javascript.ts

+7-13
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,21 @@ interface DiagnosticSourceFile extends ts.SourceFile {
3131

3232
function validateDiagnostics(diagnostics: ReadonlyArray<ts.Diagnostic>, strict?: boolean): boolean {
3333
// Print error diagnostics.
34-
const checkDiagnostics = (diagnostics: ReadonlyArray<ts.Diagnostic>) => {
35-
if (diagnostics && diagnostics.length > 0) {
36-
let errors = '';
37-
errors = errors + '\n' + ts.formatDiagnostics(diagnostics, {
38-
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
39-
getNewLine: () => ts.sys.newLine,
40-
getCanonicalFileName: (f: string) => f,
41-
});
42-
43-
return errors;
44-
}
45-
};
4634

4735
const hasError = diagnostics.some(diag => diag.category === ts.DiagnosticCategory.Error);
4836
if (hasError) {
4937
// Throw only if we're in strict mode, otherwise return original content.
5038
if (strict) {
39+
const errorMessages = ts.formatDiagnostics(diagnostics, {
40+
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
41+
getNewLine: () => ts.sys.newLine,
42+
getCanonicalFileName: (f: string) => f,
43+
});
44+
5145
throw new Error(`
5246
TS failed with the following error messages:
5347
54-
${checkDiagnostics(diagnostics)}
48+
${errorMessages}
5549
`);
5650
} else {
5751
return false;

0 commit comments

Comments
 (0)