import ts from 'typescript' ; import { tsSys } from '../tsSystem' ; const formatHost = { getCanonicalFileName : ( path ) => path , getCurrentDirectory : tsSys . getCurrentDirectory , getNewLine : ( ) => tsSys . newLine , } ; export function reportDiagnostic ( diagnostic ) { console . error ( 'Error' , diagnostic . code , ':' , ts . flattenDiagnosticMessageText ( diagnostic . messageText , formatHost . getNewLine ( ) ) ) ; } export function getTextForDiagnostic ( diagnostic ) { if ( diagnostic . file ) { const { line , character } = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ! ) ; const message = ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ; return `${ diagnostic . file . fileName } (${ line + 1 },${ character + 1 }): ${ message }` ; } else { return `${ ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) }` ; } } export function reportSolutionBuilderStatus ( diagnostic ) { console . info ( getTextForDiagnostic ( diagnostic ) ) ; } export function reportWatchStatusChanged ( diagnostic ) { console . info ( ts . formatDiagnostic ( diagnostic , formatHost ) ) ; }