@@ -614,19 +614,21 @@ const Zone: ZoneType = (function(global: any) {
614
614
return this . _zoneDelegate . fork ( this , zoneSpec ) ;
615
615
}
616
616
617
- public wrap ( callback : Function , source : string ) : Function {
617
+ public wrap < T extends Function > ( callback : T , source : string ) : T {
618
618
if ( typeof callback !== 'function' ) {
619
619
throw new Error ( 'Expecting function got: ' + callback ) ;
620
620
}
621
621
const _callback = this . _zoneDelegate . intercept ( this , callback , source ) ;
622
622
const zone : Zone = this ;
623
623
return function ( ) {
624
624
return zone . runGuarded ( _callback , this , < any > arguments , source ) ;
625
- } ;
625
+ } as any as T ;
626
626
}
627
627
628
- public run (
629
- callback : Function , applyThis : any = null , applyArgs : any [ ] = null , source : string = null ) {
628
+ public run ( callback : Function , applyThis ?: any , applyArgs ?: any [ ] , source ?: string ) : any ;
629
+ public run < T > (
630
+ callback : ( ...args : any [ ] ) => T , applyThis : any = null , applyArgs : any [ ] = null ,
631
+ source : string = null ) : T {
630
632
_currentZoneFrame = new ZoneFrame ( _currentZoneFrame , this ) ;
631
633
try {
632
634
return this . _zoneDelegate . invoke ( this , callback , applyThis , applyArgs , source ) ;
@@ -635,8 +637,10 @@ const Zone: ZoneType = (function(global: any) {
635
637
}
636
638
}
637
639
638
- public runGuarded (
639
- callback : Function , applyThis : any = null , applyArgs : any [ ] = null , source : string = null ) {
640
+ public runGuarded ( callback : Function , applyThis ?: any , applyArgs ?: any [ ] , source ?: string ) : any ;
641
+ public runGuarded < T > (
642
+ callback : ( ...args : any [ ] ) => T , applyThis : any = null , applyArgs : any [ ] = null ,
643
+ source : string = null ) {
640
644
_currentZoneFrame = new ZoneFrame ( _currentZoneFrame , this ) ;
641
645
try {
642
646
try {
@@ -652,7 +656,7 @@ const Zone: ZoneType = (function(global: any) {
652
656
}
653
657
654
658
655
- runTask ( task : Task , applyThis ?: any , applyArgs ?: any ) {
659
+ runTask ( task : Task , applyThis ?: any , applyArgs ?: any ) : any {
656
660
task . runCount ++ ;
657
661
if ( task . zone != this )
658
662
throw new Error (
0 commit comments