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 24, 2020
1 parent 7f82a2c commit 3417b9f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions packages/zone.js/lib/zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,12 +674,6 @@ type AmbientZone = Zone;
/** @internal */
type AmbientZoneDelegate = ZoneDelegate;

// CommonJS / Node have global context exposed as "global" variable.
// 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;

const Zone: ZoneType = (function(global: any) {
const performance: {mark(name: string): void; measure(name: string, label: string): void;} =
global['performance'];
Expand Down Expand Up @@ -1440,4 +1434,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 3417b9f

Please sign in to comment.