@@ -250,8 +250,8 @@ namespace ts {
250250 let compilerOptions : CompilerOptions ; // Compiler options for compilation
251251 let compilerHost : CompilerHost ; // Compiler host
252252 let hostGetSourceFile : typeof compilerHost . getSourceFile ; // getSourceFile method from default host
253- let timerHandleForRecompilation : number ; // Handle for 0.25s wait timer to trigger recompilation
254- let timerHandleForDirectoryChanges : number ; // Handle for 0.25s wait timer to trigger directory change handler
253+ let timerHandleForRecompilation : any ; // Handle for 0.25s wait timer to trigger recompilation
254+ let timerHandleForDirectoryChanges : any ; // Handle for 0.25s wait timer to trigger directory change handler
255255
256256 // This map stores and reuses results of fileExists check that happen inside 'createProgram'
257257 // This allows to save time in module resolution heavy scenarios when existence of the same file might be checked multiple times.
@@ -503,10 +503,14 @@ namespace ts {
503503 }
504504
505505 function startTimerForHandlingDirectoryChanges ( ) {
506+ if ( ! sys . setTimeout || ! sys . clearTimeout ) {
507+ return ;
508+ }
509+
506510 if ( timerHandleForDirectoryChanges ) {
507- clearTimeout ( timerHandleForDirectoryChanges ) ;
511+ sys . clearTimeout ( timerHandleForDirectoryChanges ) ;
508512 }
509- timerHandleForDirectoryChanges = setTimeout ( directoryChangeHandler , 250 ) ;
513+ timerHandleForDirectoryChanges = sys . setTimeout ( directoryChangeHandler , 250 ) ;
510514 }
511515
512516 function directoryChangeHandler ( ) {
@@ -525,10 +529,14 @@ namespace ts {
525529 // operations (such as saving all modified files in an editor) a chance to complete before we kick
526530 // off a new compilation.
527531 function startTimerForRecompilation ( ) {
532+ if ( ! sys . setTimeout || ! sys . clearTimeout ) {
533+ return ;
534+ }
535+
528536 if ( timerHandleForRecompilation ) {
529- clearTimeout ( timerHandleForRecompilation ) ;
537+ sys . clearTimeout ( timerHandleForRecompilation ) ;
530538 }
531- timerHandleForRecompilation = setTimeout ( recompile , 250 ) ;
539+ timerHandleForRecompilation = sys . setTimeout ( recompile , 250 ) ;
532540 }
533541
534542 function recompile ( ) {
0 commit comments