Skip to content

Commit

Permalink
fix(zone.js): remove global declaration
Browse files Browse the repository at this point in the history
Close angular#37531

Remove `global` declaration in `zone.ts` to avoid compile error when
upgrade to `@types/node` v14.0.5. Since the new type of global become
`Global` and not compatible with `zone.ts` declaration.
  • Loading branch information
JiaLiPassion committed Jul 30, 2020
1 parent 8effc83 commit b26e108
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/zone.js/lib/zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ type AmbientZoneDelegate = ZoneDelegate;
// This code should run in a Browser, so we don't want to include the whole node.d.ts
// typings for this compilation unit.
// We'll just fake the global "global" var for now.
declare var global: NodeJS.Global;
declare var global: any;

const Zone: ZoneType = (function(global: any) {
const performance: {mark(name: string): void; measure(name: string, label: string): void;} =
Expand Down Expand Up @@ -1440,4 +1440,5 @@ const Zone: ZoneType = (function(global: any) {

performanceMeasure('Zone', 'Zone');
return global['Zone'] = Zone;
})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self ||
typeof global !== 'undefined' && global);
2 changes: 1 addition & 1 deletion packages/zone.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test": "test"
},
"devDependencies": {
"@types/node": "^10.9.4",
"@types/node": "^14.0.5",
"domino": "2.1.2",
"jest": "^25.1.0",
"mocha": "^3.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/zone.js/test/common/zone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ describe('Zone', function() {

const ZoneAwarePromise = global.Promise;
try {
global.Promise = WrongPromise;
(global as any).Promise = WrongPromise;
expect(Zone.assertZonePatched()).toThrow();
} finally {
// restore it.
Expand Down

0 comments on commit b26e108

Please sign in to comment.