import { CompilerOptions , getDefaultCompilerOptions , IScriptSnapshot , CompilerHost , LanguageServiceHost , versionMajorMinor , ParseConfigHost } from 'typescript' ; type MixinHost = LanguageServiceHost & CompilerHost ; class MixinHostImpl { getCompilationSettings ( ) { return getDefaultCompilerOptions ( ) ; } getScriptFileNames ( ) { return [ ] ; } getScriptVersion ( ) { return versionMajorMinor ; } getScriptSnapshot ( ) { return undefined ; } } export function mixinHost ( host ) { const mixinHost = host as MixinHost ; const proxy = new MixinHostImpl ( ) ; mixinHost . getCompilationSettings = mixinHost . getCompilationSettings || proxy . getCompilationSettings ; mixinHost . getScriptFileNames = mixinHost . getScriptFileNames || proxy . getScriptFileNames ; mixinHost . getScriptVersion = mixinHost . getScriptVersion || proxy . getScriptVersion ; mixinHost . getScriptSnapshot = mixinHost . getScriptSnapshot || proxy . getScriptSnapshot ; return mixinHost ; } export class ParseConfigHostImpl implements ParseConfigHost { useCaseSensitiveFileNames : boolean ; constructor ( private compilerHost ) { this . useCaseSensitiveFileNames = compilerHost . useCaseSensitiveFileNames ( ) ; } readDirectory ( rootDir , extensions , excludes , includes , depth ? ) { return ( this . compilerHost . readDirectory ?. ( rootDir , extensions , excludes , includes , depth ) || [ ] ) ; } fileExists ( path ) { return this . compilerHost . fileExists ( path ) ; } readFile ( path ) { return this . compilerHost . readFile ( path ) ; } }