* Prints the diagnostics to stdout. * @param {typeof ts} compiler The TypeScript compiler that produced them. * @param {ts.Diagnostic[]} diagnostics The diagnostics to report.
(compiler, diagnostics)
| 138 | * @param {ts.Diagnostic[]} diagnostics The diagnostics to report. |
| 139 | */ |
| 140 | function printDiagnostics(compiler, diagnostics) { |
| 141 | diagnostics.forEach((diagnostic) => { |
| 142 | let message = ''; |
| 143 | |
| 144 | if (diagnostic.file && diagnostic.start) { |
| 145 | let start = diagnostic.file.getLineAndCharacterOfPosition( |
| 146 | diagnostic.start |
| 147 | ); |
| 148 | |
| 149 | message += ` ${diagnostic.file.fileName} (${start.line + 1},${ |
| 150 | start.character + 1 |
| 151 | })`; |
| 152 | } |
| 153 | |
| 154 | message += |
| 155 | ': ' + |
| 156 | compiler.flattenDiagnosticMessageText(diagnostic.messageText, ' \n'); |
| 157 | |
| 158 | process.stdout.write(`\x1b[30m ${message}\x1b[0m\n`); |
| 159 | }); |
| 160 | } |