Skip to content

Commit 393b052

Browse files
committed
refactor(NgZone): improve types
Closes angular#4642
1 parent 6207b1a commit 393b052

2 files changed

Lines changed: 8 additions & 17 deletions

File tree

modules/angular2/src/core/zone/ng_zone.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ export class NgZone {
9393
_onErrorHandler: (error: any, stack: any) => void;
9494

9595
// Number of microtasks pending from _innerZone (& descendants)
96-
_pendingMicrotasks: number;
96+
_pendingMicrotasks: number = 0;
9797
// Whether some code has been executed in the _innerZone (& descendants) in the current turn
98-
_hasExecutedCodeInInnerZone: boolean;
98+
_hasExecutedCodeInInnerZone: boolean = false;
9999
// run() call depth in _mountZone. 0 at the end of a macrotask
100100
// zone.run(() => { // top-level call
101101
// zone.run(() => {}); // nested call -> in-turn
102102
// });
103-
_nestedRun: number;
103+
_nestedRun: number = 0;
104104

105105
// TODO(vicb): implement this class properly for node.js environment
106106
// This disabled flag is only here to please cjs tests
@@ -115,15 +115,6 @@ export class NgZone {
115115
* enabled in development mode as they significantly impact perf.
116116
*/
117117
constructor({enableLongStackTrace}) {
118-
this._onTurnStart = null;
119-
this._onTurnDone = null;
120-
this._onEventDone = null;
121-
this._onErrorHandler = null;
122-
123-
this._pendingMicrotasks = 0;
124-
this._hasExecutedCodeInInnerZone = false;
125-
this._nestedRun = 0;
126-
127118
if (global.zone) {
128119
this._disabled = false;
129120
this._mountZone = global.zone;
@@ -142,7 +133,7 @@ export class NgZone {
142133
*
143134
* Setting the hook overrides any previously set hook.
144135
*/
145-
overrideOnTurnStart(onTurnStartHook: Function): void {
136+
overrideOnTurnStart(onTurnStartHook: () => void): void {
146137
this._onTurnStart = normalizeBlank(onTurnStartHook);
147138
}
148139

@@ -156,7 +147,7 @@ export class NgZone {
156147
*
157148
* Setting the hook overrides any previously set hook.
158149
*/
159-
overrideOnTurnDone(onTurnDoneHook: Function): void {
150+
overrideOnTurnDone(onTurnDoneHook: () => void): void {
160151
this._onTurnDone = normalizeBlank(onTurnDoneHook);
161152
}
162153

@@ -171,7 +162,7 @@ export class NgZone {
171162
*
172163
* Setting the hook overrides any previously set hook.
173164
*/
174-
overrideOnEventDone(onEventDoneFn: Function, opt_waitForAsync: boolean = false): void {
165+
overrideOnEventDone(onEventDoneFn: () => void, opt_waitForAsync: boolean = false): void {
175166
var normalizedOnEventDone = normalizeBlank(onEventDoneFn);
176167
if (opt_waitForAsync) {
177168
this._onEventDone = () => {
@@ -242,7 +233,7 @@ export class NgZone {
242233
var errorHandling;
243234

244235
if (enableLongStackTrace) {
245-
errorHandling = StringMapWrapper.merge(<any>Zone.longStackTraceZone,
236+
errorHandling = StringMapWrapper.merge(Zone.longStackTraceZone,
246237
{onError: function(e) { ngZone._onError(this, e); }});
247238
} else {
248239
errorHandling = {onError: function(e) { ngZone._onError(this, e); }};

modules/angular2/tsd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"commit": "be0b6b394f77a59e192ad7cfec18078706e44db5"
2222
},
2323
"zone/zone.d.ts": {
24-
"commit": "055b3172e8eb374a75826710c4d08677872620d3"
24+
"commit": "31e7317c9a0793857109236ef7c7f223305a8aa9"
2525
},
2626
"angular-protractor/angular-protractor.d.ts": {
2727
"commit": "4207593c012565a7ea800ed861ffbe5011e7a501"

0 commit comments

Comments
 (0)