import type * as fs from 'fs' ; export type FileWatcherEventType = 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir' ; export type FileWatcherEventHandler = ( eventName : FileWatcherEventType , path : string , stats ? : Stats ) => void ; export interface FileWatcher { close ( ) : void ; } export interface FileWatcherProvider { createFileWatcher ( paths , listener ) : FileWatcher ; onFileChange ( eventType , path ) : void ; } export interface Stats { size : number ; isFile ( ) : boolean ; isDirectory ( ) : boolean ; isBlockDevice ( ) : boolean ; isCharacterDevice ( ) : boolean ; isSymbolicLink ( ) : boolean ; isFIFO ( ) : boolean ; isSocket ( ) : boolean ; } export interface MkDirOptions { recursive : boolean ; } export interface TmpfileOptions { postfix ? : string ; prefix ? : string ; } export interface FileSystem { existsSync ( path ) : boolean ; mkdirSync ( path , options ? ) : void ; chdir ( path ) : void ; readdirEntriesSync ( path ) : fs . Dirent [ ] ; readdirSync ( path ) : string [ ] ; readFileSync ( path , encoding ? ) : Buffer ; readFileSync ( path , encoding ) : string ; readFileSync ( path , encoding ? ) : string | Buffer ; writeFileSync ( path , data , encoding ) : void ; statSync ( path ) : Stats ; unlinkSync ( path ) : void ; realpathSync ( path ) : string ; getModulePath ( ) : string ; createFileSystemWatcher ( paths , listener ) : FileWatcher ; createReadStream ( path ) : fs . ReadStream ; createWriteStream ( path ) : fs . WriteStream ; copyFileSync ( src , dst ) : void ; readFile ( path ) : Promise < Buffer > ; readFileText ( path , encoding ? ) : Promise < string > ; tmpdir ( ) : string ; tmpfile ( options ? ) : string ; realCasePath ( path ) : string ; isMappedFilePath ( filepath ) : boolean ; getOriginalFilePath ( mappedFilePath ) : string ; getMappedFilePath ( originalFilepath ) : string ; getUri ( path ) : string ; isInZipOrEgg ( path ) : boolean ; } export function ignoredWatchEventFunction ( paths ) { const normalizedPaths = paths . map ( ( p ) => p . toLowerCase ( ) ) ; return ( path ) : boolean => { if ( ! path || path . indexOf ( '__pycache__' ) >= 0 ) { return true ; } const normalizedPath = path . toLowerCase ( ) ; return normalizedPaths . every ( ( p ) => normalizedPath . indexOf ( p ) < 0 ) ; } ; } const nullFileWatcher = { close ( ) { } , } ; export const nullFileWatcherProvider = { createFileWatcher ( _1 , _2 ) { return nullFileWatcher ; } , onFileChange ( _1 , _2 ) { } , } ; export class VirtualDirent implements fs . Dirent { constructor ( public name , private _file ) { } isFile ( ) { return this . _file ; } isDirectory ( ) { return ! this . _file ; } isBlockDevice ( ) { return false ; } isCharacterDevice ( ) { return false ; } isSymbolicLink ( ) { return false ; } isFIFO ( ) { return false ; } isSocket ( ) { return false ; } }