import * as ts from 'typescript' ; import * as fs from 'fs' ; public export function getLanguageService ( uniqFiles ) { return ts . createLanguageService ( { getCompilationSettings ( ) { return { jsx : ts . JsxEmit . React } ; } , getScriptFileNames ( ) { return uniqFiles ; } , getScriptVersion ( ) { return '' ; } , getScriptSnapshot ( fileName ) { if ( fileName === '.ts' ) { return ts . ScriptSnapshot . fromString ( '' ) ; } return ts . ScriptSnapshot . fromString ( fs . readFileSync ( fileName , { encoding : 'utf8' } ) ) ; } , getCurrentDirectory : ( ) => '.' , getDefaultLibFileName ( options ) { return ts . getDefaultLibFilePath ( options ) ; } , fileExists : ts . sys . fileExists , readFile : ts . sys . readFile , readDirectory : ts . sys . readDirectory } ) ; }