refactor(zone.js): change from scripts to modules (#53445)

Make Zone.js compatible with moduleDetection:force by turning files that
are currently incompatible from scripts into modules using an empty
export statement.

PR Close #53445
This commit is contained in:
Jan Kuehle
2023-12-08 09:48:30 +00:00
committed by Andrew Scott
parent 92fd6cc42e
commit b3aec87f57
6 changed files with 2120 additions and 2090 deletions
+14 -10
View File
@@ -10,19 +10,21 @@
* @suppress {globalThis,undefinedVars}
*/
/**
* Extend the Error with additional fields for rewritten stack frames
*/
interface Error {
declare global {
/**
* Stack trace where extra frames have been removed and zone names added.
* Extend the Error with additional fields for rewritten stack frames
*/
zoneAwareStack?: string;
interface Error {
/**
* Stack trace where extra frames have been removed and zone names added.
*/
zoneAwareStack?: string;
/**
* Original stack trace with no modifications
*/
originalStack?: string;
/**
* Original stack trace with no modifications
*/
originalStack?: string;
}
}
Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
@@ -394,3 +396,5 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
(Error as any).stackTraceLimit = originalStackTraceLimit;
});
export {};
+36 -32
View File
@@ -6,39 +6,43 @@
* found in the LICENSE file at https://angular.io/license
*/
/**
* Additional `EventTarget` methods added by `Zone.js`.
*
* 1. removeAllListeners, remove all event listeners of the given event name.
* 2. eventListeners, get all event listeners of the given event name.
*/
interface EventTarget {
declare global {
/**
* Additional `EventTarget` methods added by `Zone.js`.
*
* Remove all event listeners by name for this event target.
*
* This method is optional because it may not be available if you use `noop zone` when
* bootstrapping Angular application or disable the `EventTarget` monkey patch by `zone.js`.
*
* If the `eventName` is provided, will remove event listeners of that name.
* If the `eventName` is not provided, will remove all event listeners associated with
* `EventTarget`.
*
* @param eventName the name of the event, such as `click`. This parameter is optional.
* 1. removeAllListeners, remove all event listeners of the given event name.
* 2. eventListeners, get all event listeners of the given event name.
*/
removeAllListeners?(eventName?: string): void;
/**
*
* Retrieve all event listeners by name.
*
* This method is optional because it may not be available if you use `noop zone` when
* bootstrapping Angular application or disable the `EventTarget` monkey patch by `zone.js`.
*
* If the `eventName` is provided, will return an array of event handlers or event listener
* objects of the given event.
* If the `eventName` is not provided, will return all listeners.
*
* @param eventName the name of the event, such as click. This parameter is optional.
*/
eventListeners?(eventName?: string): EventListenerOrEventListenerObject[];
interface EventTarget {
/**
*
* Remove all event listeners by name for this event target.
*
* This method is optional because it may not be available if you use `noop zone` when
* bootstrapping Angular application or disable the `EventTarget` monkey patch by `zone.js`.
*
* If the `eventName` is provided, will remove event listeners of that name.
* If the `eventName` is not provided, will remove all event listeners associated with
* `EventTarget`.
*
* @param eventName the name of the event, such as `click`. This parameter is optional.
*/
removeAllListeners?(eventName?: string): void;
/**
*
* Retrieve all event listeners by name.
*
* This method is optional because it may not be available if you use `noop zone` when
* bootstrapping Angular application or disable the `EventTarget` monkey patch by `zone.js`.
*
* If the `eventName` is provided, will return an array of event handlers or event listener
* objects of the given event.
* If the `eventName` is not provided, will return all listeners.
*
* @param eventName the name of the event, such as click. This parameter is optional.
*/
eventListeners?(eventName?: string): EventListenerOrEventListenerObject[];
}
}
export {};
File diff suppressed because it is too large Load Diff
+1290 -1281
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -116,6 +116,7 @@ ts_library(
deps = [
":common_spec_env",
"//packages/zone.js/lib",
"//packages/zone.js/lib:zone_d_ts",
"@npm//bluebird",
],
)
@@ -139,6 +140,7 @@ ts_library(
deps = [
":common_spec_env",
"//packages/zone.js/lib",
"//packages/zone.js/lib:zone_d_ts",
],
)
@@ -50,7 +50,8 @@ describe('Zone.js npm_package', () => {
describe('check npm_package root folder', () => {
describe('typescript support', () => {
it('should have an zone.d.ts file', () => {
expect(shx.cat('zone.d.ts')).toContain('declare const');
expect(shx.cat('zone.d.ts')).toContain('declare global {');
expect(shx.cat('zone.d.ts')).toContain('const Zone');
expect(shx.cat('zone.d.ts')).toContain('interface EventTarget');
expect(shx.cat('zone.d.ts')).toContain('ZoneGlobalConfigurations');
});