chore: use interface types in ng_zone/JS

This commit is contained in:
Yegor Jbanov 2015-10-12 17:20:00 -07:00
parent 711dbf4975
commit a7c95ade2e
1 changed files with 16 additions and 8 deletions

View File

@ -8,6 +8,14 @@ export interface NgZoneZone extends Zone {
_innerZone: boolean; _innerZone: boolean;
} }
export interface ZeroArgFunction {
(): void;
}
export interface ErrorHandlingFn {
(error: any, stackTrace: any): void;
}
/** /**
* An injectable service for executing work inside or outside of the Angular zone. * An injectable service for executing work inside or outside of the Angular zone.
* *
@ -93,13 +101,13 @@ export class NgZone {
_innerZone; _innerZone;
/** @internal */ /** @internal */
_onTurnStart: () => void; _onTurnStart: ZeroArgFunction;
/** @internal */ /** @internal */
_onTurnDone: () => void; _onTurnDone: ZeroArgFunction;
/** @internal */ /** @internal */
_onEventDone: () => void; _onEventDone: ZeroArgFunction;
/** @internal */ /** @internal */
_onErrorHandler: (error: any, stack: any) => void; _onErrorHandler: ErrorHandlingFn;
// Number of microtasks pending from _innerZone (& descendants) // Number of microtasks pending from _innerZone (& descendants)
/** @internal */ /** @internal */
@ -148,7 +156,7 @@ export class NgZone {
* *
* Setting the hook overrides any previously set hook. * Setting the hook overrides any previously set hook.
*/ */
overrideOnTurnStart(onTurnStartHook: () => void): void { overrideOnTurnStart(onTurnStartHook: ZeroArgFunction): void {
this._onTurnStart = normalizeBlank(onTurnStartHook); this._onTurnStart = normalizeBlank(onTurnStartHook);
} }
@ -162,7 +170,7 @@ export class NgZone {
* *
* Setting the hook overrides any previously set hook. * Setting the hook overrides any previously set hook.
*/ */
overrideOnTurnDone(onTurnDoneHook: () => void): void { overrideOnTurnDone(onTurnDoneHook: ZeroArgFunction): void {
this._onTurnDone = normalizeBlank(onTurnDoneHook); this._onTurnDone = normalizeBlank(onTurnDoneHook);
} }
@ -177,7 +185,7 @@ export class NgZone {
* *
* Setting the hook overrides any previously set hook. * Setting the hook overrides any previously set hook.
*/ */
overrideOnEventDone(onEventDoneFn: () => void, opt_waitForAsync: boolean = false): void { overrideOnEventDone(onEventDoneFn: ZeroArgFunction, opt_waitForAsync: boolean = false): void {
var normalizedOnEventDone = normalizeBlank(onEventDoneFn); var normalizedOnEventDone = normalizeBlank(onEventDoneFn);
if (opt_waitForAsync) { if (opt_waitForAsync) {
this._onEventDone = () => { this._onEventDone = () => {
@ -195,7 +203,7 @@ export class NgZone {
* *
* Setting the hook overrides any previously set hook. * Setting the hook overrides any previously set hook.
*/ */
overrideOnErrorHandler(errorHandler: (error: Error, stack: string) => void) { overrideOnErrorHandler(errorHandler: ErrorHandlingFn) {
this._onErrorHandler = normalizeBlank(errorHandler); this._onErrorHandler = normalizeBlank(errorHandler);
} }