mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
@@ -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 {};
|
||||
|
||||
@@ -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
File diff suppressed because it is too large
Load Diff
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user