import ts = require ( 'typescript' ) ; function printMessage ( messageText ) { if ( messageText [ 'messageText' ] ) { return printMessage ( ( < ts . DiagnosticMessageChain > messageText ) . messageText ) ; } else { return messageText . toString ( ) ; } } export function printDiagnostic ( diagnostic ) { const linePos = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ) ; const message = printMessage ( diagnostic . messageText ) ; return `${ diagnostic . file . fileName } -> ${ linePos . line + 1 }:${ linePos . character } ${ message }` ; }