fix: make sure that Zone does not show up in angular2.d.ts
Closes #7655
This commit is contained in:
parent
048bd280dd
commit
d4e9b55fb6
|
@ -988,7 +988,7 @@ gulp.task('test.typings',
|
|||
['!pre.test.typings.layoutNodeModule', '!pre.test.typings.copyTypingsSpec'], function() {
|
||||
var tsc = require('gulp-typescript');
|
||||
|
||||
return gulp.src([tmpdir + '/*.ts', 'node_modules/zone.js/dist/zone.js.d.ts'])
|
||||
return gulp.src([tmpdir + '/*.ts'])
|
||||
.pipe(tsc({
|
||||
target: 'ES6',
|
||||
module: 'commonjs',
|
||||
|
|
|
@ -8,13 +8,12 @@ export class NgZoneError {
|
|||
}
|
||||
|
||||
|
||||
export class NgZoneImpl implements ZoneSpec {
|
||||
export class NgZoneImpl {
|
||||
static isInAngularZone(): boolean { return Zone.current.get('isAngularZone') === true; }
|
||||
|
||||
public name: string = 'angular';
|
||||
public properties: {[k: string]: string} = <any>{'isAngularZone': true};
|
||||
|
||||
/** @internal */
|
||||
private outer: Zone;
|
||||
/** @internal */
|
||||
private inner: Zone;
|
||||
|
||||
private onEnter: () => void;
|
||||
|
@ -37,7 +36,7 @@ export class NgZoneImpl implements ZoneSpec {
|
|||
this.setMacrotask = setMacrotask;
|
||||
this.onError = onError;
|
||||
|
||||
if (global.Zone) {
|
||||
if (Zone) {
|
||||
this.outer = this.inner = Zone.current;
|
||||
if (Zone['wtfZoneSpec']) {
|
||||
this.inner = this.inner.fork(Zone['wtfZoneSpec']);
|
||||
|
@ -45,34 +44,32 @@ export class NgZoneImpl implements ZoneSpec {
|
|||
if (trace) {
|
||||
this.inner = this.inner.fork(Zone['longStackTraceZoneSpec']);
|
||||
}
|
||||
this.inner = this.inner.fork(this);
|
||||
} else {
|
||||
throw new Error('Angular2 needs to be run with Zone.js polyfill.');
|
||||
}
|
||||
}
|
||||
|
||||
onInvokeTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task, applyThis: any,
|
||||
applyArgs: any): any {
|
||||
this.inner = this.inner.fork({
|
||||
name: 'angular',
|
||||
properties:<any>{'isAngularZone': true},
|
||||
onInvokeTask: (delegate: ZoneDelegate, current: Zone, target: Zone, task: Task,
|
||||
applyThis: any, applyArgs: any): any => {
|
||||
try {
|
||||
this.onEnter();
|
||||
return delegate.invokeTask(target, task, applyThis, applyArgs);
|
||||
} finally {
|
||||
this.onLeave();
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
onInvoke(delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function, applyThis: any,
|
||||
applyArgs: any[], source: string): any {
|
||||
onInvoke: (delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function,
|
||||
applyThis: any, applyArgs: any[], source: string): any => {
|
||||
try {
|
||||
this.onEnter();
|
||||
return delegate.invoke(target, callback, applyThis, applyArgs, source);
|
||||
} finally {
|
||||
this.onLeave();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState) {
|
||||
onHasTask:
|
||||
(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState) => {
|
||||
delegate.hasTask(target, hasTaskState);
|
||||
if (current == target) {
|
||||
// We are only interested in hasTask events which originate from our zone
|
||||
|
@ -83,13 +80,19 @@ export class NgZoneImpl implements ZoneSpec {
|
|||
this.setMacrotask(hasTaskState.macroTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onHandleError(delegate: ZoneDelegate, current: Zone, target: Zone, error: any): boolean {
|
||||
onHandleError: (delegate: ZoneDelegate, current: Zone, target: Zone, error: any):
|
||||
boolean => {
|
||||
delegate.handleError(target, error);
|
||||
this.onError(new NgZoneError(error, error.stack));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
throw new Error('Angular2 needs to be run with Zone.js polyfill.');
|
||||
}
|
||||
}
|
||||
|
||||
runInner(fn: () => any): any { return this.inner.runGuarded(fn); };
|
||||
runOuter(fn: () => any): any { return this.outer.run(fn); };
|
||||
|
|
|
@ -9,7 +9,6 @@ export interface BrowserNodeGlobal {
|
|||
Math: any; // typeof Math;
|
||||
assert(condition: any): void;
|
||||
Reflect: any;
|
||||
Zone: typeof Zone;
|
||||
getAngularTestability: Function;
|
||||
getAllAngularTestabilities: Function;
|
||||
getAllAngularRootElements: Function;
|
||||
|
|
Loading…
Reference in New Issue