MCPcopy Create free account
hub / github.com/nodejs/node / createDiagnosticReporter

Function createDiagnosticReporter

test/fixtures/snapshot/typescript.js:122694–122709  ·  view source on GitHub ↗

* Create a function that reports error by writing to the system and handles the formatting of the diagnostic

(system, pretty)

Source from the content-addressed store, hash-verified

122692 * Create a function that reports error by writing to the system and handles the formatting of the diagnostic
122693 */
122694 function createDiagnosticReporter(system, pretty) {
122695 var host = system === ts.sys && sysFormatDiagnosticsHost ? sysFormatDiagnosticsHost : {
122696 getCurrentDirectory: function () { return system.getCurrentDirectory(); },
122697 getNewLine: function () { return system.newLine; },
122698 getCanonicalFileName: ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames),
122699 };
122700 if (!pretty) {
122701 return function (diagnostic) { return system.write(ts.formatDiagnostic(diagnostic, host)); };
122702 }
122703 var diagnostics = new Array(1);
122704 return function (diagnostic) {
122705 diagnostics[0] = diagnostic;
122706 system.write(ts.formatDiagnosticsWithColorAndContext(diagnostics, host) + host.getNewLine());
122707 diagnostics[0] = undefined; // TODO: GH#18217
122708 };
122709 }
122710 ts.createDiagnosticReporter = createDiagnosticReporter;
122711 /**
122712 * @returns Whether the screen was cleared.

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected