How to use the formatDiagnostics function from typescript

Find comprehensive JavaScript typescript.formatDiagnostics code examples handpicked from public code repositorys.

5
6
7
8
9
10
11
12
13
14
// Print error diagnostics.
const hasError = diagnostics.some(diag => diag.category === ts.DiagnosticCategory.Error);
if (hasError) {
    // Throw only if we're in strict mode, otherwise return original content.
    if (strict) {
        const errorMessages = ts.formatDiagnostics(diagnostics, {
            getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
            getNewLine: () => ts.sys.newLine,
            getCanonicalFileName: (f) => f,
        });
fork icon0
star icon0
watch icon1

Other functions in typescript

Sorted by popularity

function icon

typescript.SyntaxKind is the most popular function in typescript (82777 examples)