fix(zone.js): don't rely on global node typings outside of node/ directory (#31783)

PR Close #31783
This commit is contained in:
Alex Eagle
2019-07-22 10:59:42 -07:00
committed by Andrew Kushnir
parent 3479fddf68
commit 5c9a8961da
3 changed files with 23 additions and 14 deletions

View File

@ -331,8 +331,9 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
// we need to detect all zone related frames, it will
// exceed default stackTraceLimit, so we set it to
// larger number here, and restore it after detect finish.
const originalStackTraceLimit = Error.stackTraceLimit;
Error.stackTraceLimit = 100;
// We cast through any so we don't need to depend on nodejs typings.
const originalStackTraceLimit = (Error as any).stackTraceLimit;
(Error as any).stackTraceLimit = 100;
// we schedule event/micro/macro task, and invoke them
// when onSchedule, so we can get all stack traces for
// all kinds of tasks with one error thrown.
@ -374,5 +375,5 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
});
});
Error.stackTraceLimit = originalStackTraceLimit;
(Error as any).stackTraceLimit = originalStackTraceLimit;
});