22
33namespace ts {
44 export type FileWatcherCallback = ( path : string , removed ?: boolean ) => void ;
5- export type DirWatcherCallback = ( path : string ) => void ;
5+ export type DirectoryWatcherCallback = ( path : string ) => void ;
66
77 export interface System {
88 args : string [ ] ;
@@ -12,7 +12,7 @@ namespace ts {
1212 readFile ( path : string , encoding ?: string ) : string ;
1313 writeFile ( path : string , data : string , writeByteOrderMark ?: boolean ) : void ;
1414 watchFile ?( path : string , callback : FileWatcherCallback ) : FileWatcher ;
15- watchDirectory ?( path : string , callback : DirWatcherCallback , recursive ?: boolean ) : FileWatcher ;
15+ watchDirectory ?( path : string , callback : DirectoryWatcherCallback , recursive ?: boolean ) : FileWatcher ;
1616 resolvePath ( path : string ) : string ;
1717 fileExists ( path : string ) : boolean ;
1818 directoryExists ( path : string ) : boolean ;
@@ -34,7 +34,7 @@ namespace ts {
3434 close ( ) : void ;
3535 }
3636
37- export interface DirWatcher extends FileWatcher {
37+ export interface DirectoryWatcher extends FileWatcher {
3838 referenceCount : number ;
3939 }
4040
@@ -70,7 +70,7 @@ namespace ts {
7070 writeFile ( path : string , contents : string ) : void ;
7171 readDirectory ( path : string , extension ?: string , exclude ?: string [ ] ) : string [ ] ;
7272 watchFile ?( path : string , callback : FileWatcherCallback ) : FileWatcher ;
73- watchDirectory ?( path : string , callback : DirWatcherCallback , recursive ?: boolean ) : FileWatcher ;
73+ watchDirectory ?( path : string , callback : DirectoryWatcherCallback , recursive ?: boolean ) : FileWatcher ;
7474 } ;
7575
7676 export var sys : System = ( function ( ) {
@@ -305,16 +305,16 @@ namespace ts {
305305 }
306306
307307 function createWatchedFileSet ( ) {
308- const dirWatchers = createFileMap < DirWatcher > ( ) ;
309- const recursiveDirWatchers = createFileMap < DirWatcher > ( ) ;
308+ const dirWatchers = createFileMap < DirectoryWatcher > ( ) ;
309+ const recursiveDirWatchers = createFileMap < DirectoryWatcher > ( ) ;
310310 // One file can have multiple watchers
311311 const fileWatcherCallbacks = createFileMap < FileWatcherCallback [ ] > ( ) ;
312- const dirWatcherCallbacks = createFileMap < DirWatcherCallback [ ] > ( ) ;
312+ const dirWatcherCallbacks = createFileMap < DirectoryWatcherCallback [ ] > ( ) ;
313313
314314 const currentDirectory = process . cwd ( ) ;
315315 return { addFile, removeFile, addDir } ;
316316
317- function addDir ( dirName : string , callback : DirWatcherCallback , recursive ?: boolean ) {
317+ function addDir ( dirName : string , callback : DirectoryWatcherCallback , recursive ?: boolean ) {
318318 const dirPath = toPath ( dirName , currentDirectory , getCanonicalPath ) ;
319319 if ( ! dirWatcherCallbacks . contains ( dirPath ) ) {
320320 dirWatcherCallbacks . set ( dirPath , [ callback ] ) ;
@@ -328,7 +328,7 @@ namespace ts {
328328 } ;
329329 }
330330
331- function reduceDirWatcherRefCount ( watcher : DirWatcher , dirPath : Path , isRecursive : boolean ) {
331+ function reduceDirWatcherRefCount ( watcher : DirectoryWatcher , dirPath : Path , isRecursive : boolean ) {
332332 watcher . referenceCount -= 1 ;
333333 if ( watcher . referenceCount <= 0 ) {
334334 watcher . close ( ) ;
@@ -341,8 +341,8 @@ namespace ts {
341341 }
342342 }
343343
344- function addDirWatcher ( dirPath : Path , recursive ?: boolean ) : { watcher : DirWatcher , isRecursive : boolean } {
345- let watchers : FileMap < DirWatcher > ;
344+ function addDirWatcher ( dirPath : Path , recursive ?: boolean ) : { watcher : DirectoryWatcher , isRecursive : boolean } {
345+ let watchers : FileMap < DirectoryWatcher > ;
346346 const options : { persistent : boolean , recursive ?: boolean } = { persistent : true } ;
347347
348348 // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
@@ -367,14 +367,14 @@ namespace ts {
367367 options . recursive = false ;
368368 }
369369
370- const watcher : DirWatcher = _fs . watch ( dirPath , options , ( eventName : string , relativeFileName : string ) => fileEventHandler ( eventName , relativeFileName , dirPath ) ) ;
370+ const watcher : DirectoryWatcher = _fs . watch ( dirPath , options , ( eventName : string , relativeFileName : string ) => fileEventHandler ( eventName , relativeFileName , dirPath ) ) ;
371371 watcher . referenceCount = 1 ;
372372 watchers . set ( dirPath , watcher ) ;
373373 return { watcher, isRecursive : options . recursive } ;
374374 }
375375
376- function findDirWatcherForFile ( filePath : Path ) : { watcher : DirWatcher , watcherPath : Path , isRecursive : boolean } {
377- let watcher : DirWatcher ;
376+ function findDirWatcherForFile ( filePath : Path ) : { watcher : DirectoryWatcher , watcherPath : Path , isRecursive : boolean } {
377+ let watcher : DirectoryWatcher ;
378378 let watcherPath : Path ;
379379 let isRecursive = false ;
380380 recursiveDirWatchers . forEachValue ( dirPath => {
0 commit comments