This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree 3 files changed +23
-0
lines changed
3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -372,6 +372,10 @@ interface TaskData {
372
372
* Delay in milliseconds when the Task will run.
373
373
*/
374
374
delay ?: number ;
375
+ /**
376
+ * identifier returned by the native setTimeout.
377
+ */
378
+ handleId ?: number ;
375
379
}
376
380
/**
377
381
* Represents work which is executed with a clean stack.
Original file line number Diff line number Diff line change @@ -395,6 +395,11 @@ interface TaskData {
395
395
* Delay in milliseconds when the Task will run.
396
396
*/
397
397
delay ?: number ;
398
+
399
+ /**
400
+ * identifier returned by the native setTimeout.
401
+ */
402
+ handleId ?: number ;
398
403
}
399
404
400
405
/**
@@ -819,6 +824,14 @@ const Zone: ZoneType = (function(global: any) {
819
824
}
820
825
} ;
821
826
}
827
+
828
+ public toString ( ) {
829
+ if ( this . data && typeof this . data . handleId !== 'undefined' ) {
830
+ return this . data . handleId ;
831
+ } else {
832
+ return this . toString ( ) ;
833
+ }
834
+ }
822
835
}
823
836
824
837
interface UncaughtPromiseError extends Error {
Original file line number Diff line number Diff line change @@ -88,6 +88,12 @@ describe('setTimeout', function () {
88
88
} ) ;
89
89
} ) ;
90
90
91
+ it ( 'should return the timeout Id through toString' , function ( ) {
92
+ var cancelId = setTimeout ( ( ) => {
93
+ } , 0 ) ;
94
+ expect ( typeof cancelId . toString ( ) ) . toBe ( 'number' ) ;
95
+ } )
96
+
91
97
it ( 'should pass invalid values through' , function ( ) {
92
98
clearTimeout ( null ) ;
93
99
clearTimeout ( < any > { } ) ;
You can’t perform that action at this time.
0 commit comments