diff --git a/packages/core/src/zone/ng_zone.ts b/packages/core/src/zone/ng_zone.ts index 251eae4c9a..a8d5bb9d36 100644 --- a/packages/core/src/zone/ng_zone.ts +++ b/packages/core/src/zone/ng_zone.ts @@ -177,7 +177,7 @@ export class NgZone { * If a synchronous error happens it will be rethrown and not reported via `onError`. */ run(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[]): T { - return (this as any as NgZonePrivate)._inner.run(fn, applyThis, applyArgs) as T; + return (this as any as NgZonePrivate)._inner.run(fn, applyThis, applyArgs); } /** @@ -196,7 +196,7 @@ export class NgZone { const zone = (this as any as NgZonePrivate)._inner; const task = zone.scheduleEventTask('NgZoneEvent: ' + name, fn, EMPTY_PAYLOAD, noop, noop); try { - return zone.runTask(task, applyThis, applyArgs) as T; + return zone.runTask(task, applyThis, applyArgs); } finally { zone.cancelTask(task); } @@ -207,7 +207,7 @@ export class NgZone { * rethrown. */ runGuarded(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[]): T { - return (this as any as NgZonePrivate)._inner.runGuarded(fn, applyThis, applyArgs) as T; + return (this as any as NgZonePrivate)._inner.runGuarded(fn, applyThis, applyArgs); } /** @@ -224,7 +224,7 @@ export class NgZone { * Use {@link #run} to reenter the Angular zone and do work that updates the application model. */ runOutsideAngular(fn: (...args: any[]) => T): T { - return (this as any as NgZonePrivate)._outer.run(fn) as T; + return (this as any as NgZonePrivate)._outer.run(fn); } } @@ -388,19 +388,19 @@ export class NoopNgZone implements NgZone { readonly onStable: EventEmitter = new EventEmitter(); readonly onError: EventEmitter = new EventEmitter(); - run(fn: (...args: any[]) => any, applyThis?: any, applyArgs?: any): any { + run(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any): T { return fn.apply(applyThis, applyArgs); } - runGuarded(fn: (...args: any[]) => any, applyThis?: any, applyArgs?: any): any { + runGuarded(fn: (...args: any[]) => any, applyThis?: any, applyArgs?: any): T { return fn.apply(applyThis, applyArgs); } - runOutsideAngular(fn: (...args: any[]) => any): any { + runOutsideAngular(fn: (...args: any[]) => T): T { return fn(); } - runTask(fn: (...args: any[]) => any, applyThis?: any, applyArgs?: any, name?: string): any { + runTask(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any, name?: string): T { return fn.apply(applyThis, applyArgs); } } diff --git a/packages/zone.js/lib/zone.ts b/packages/zone.js/lib/zone.ts index 7d6b3ebaff..54c188b5a7 100644 --- a/packages/zone.js/lib/zone.ts +++ b/packages/zone.js/lib/zone.ts @@ -223,9 +223,9 @@ interface Zone { * @param task to run * @param applyThis * @param applyArgs - * @returns {*} + * @returns {any} Value from the `task.callback` function. */ - runTask(task: Task, applyThis?: any, applyArgs?: any): any; + runTask(task: Task, applyThis?: any, applyArgs?: any): T; /** * Schedule a MicroTask.