Skip to content

Commit 4bde40f

Browse files
alan-agius4benlesh
authored andcommittedApr 17, 2019
fix(core): don't include a local EventListener in typings (#29809)
With dts bundles, `core.d.ts` will include an `EventListener` class as it's used in https://github.com/angular/angular/blob/303eae918d997070a36b523ddc97e018f622c258/packages/core/src/debug/debug_node.ts#L32 This will conflict with the DOM EventListener, as anything in `core.d.ts` which is using the DOM EventListener will fallback in using the one defined in the same module and hence build will fail because their implementation is different. With this change, we rename the local `EventListener` to `DebugEventListener`, the later one is non exported. Fixes #29806 PR Close #29809
1 parent 4271d35 commit 4bde40f

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed
 

‎packages/core/src/core.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export {APP_INITIALIZER, ApplicationInitStatus} from './application_init';
2222
export * from './zone';
2323
export * from './render';
2424
export * from './linker';
25-
export {DebugElement, DebugNode, asNativeElements, getDebugNode, Predicate} from './debug/debug_node';
25+
export {DebugElement, DebugEventListener, DebugNode, asNativeElements, getDebugNode, Predicate} from './debug/debug_node';
2626
export {GetTestability, Testability, TestabilityRegistry, setTestabilityGetter} from './testability/testability';
2727
export * from './change_detection';
2828
export * from './platform_core_providers';

‎packages/core/src/debug/debug_node.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ import {getComponentViewByIndex, getNativeByTNode, isComponent, isLContainer} fr
2121
import {assertDomNode} from '../util/assert';
2222
import {DebugContext} from '../view/index';
2323

24-
export class EventListener {
24+
/**
25+
* @publicApi
26+
*/
27+
export class DebugEventListener {
2528
constructor(public name: string, public callback: Function) {}
2629
}
2730

2831
/**
2932
* @publicApi
3033
*/
3134
export interface DebugNode {
32-
readonly listeners: EventListener[];
35+
readonly listeners: DebugEventListener[];
3336
readonly parent: DebugElement|null;
3437
readonly nativeNode: any;
3538
readonly injector: Injector;
@@ -39,7 +42,7 @@ export interface DebugNode {
3942
readonly providerTokens: any[];
4043
}
4144
export class DebugNode__PRE_R3__ {
42-
readonly listeners: EventListener[] = [];
45+
readonly listeners: DebugEventListener[] = [];
4346
readonly parent: DebugElement|null = null;
4447
readonly nativeNode: any;
4548
private readonly _debugContext: DebugContext;
@@ -219,7 +222,7 @@ class DebugNode__POST_R3__ implements DebugNode {
219222
}
220223
get context(): any { return getContext(this.nativeNode as Element); }
221224

222-
get listeners(): EventListener[] {
225+
get listeners(): DebugEventListener[] {
223226
return getListeners(this.nativeNode as Element).filter(isBrowserEvents);
224227
}
225228

‎packages/core/src/view/services.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {DebugElement__PRE_R3__, DebugNode__PRE_R3__, EventListener, getDebugNode, indexDebugNode, removeDebugNodeFromIndex} from '../debug/debug_node';
9+
import {DebugElement__PRE_R3__, DebugEventListener, DebugNode__PRE_R3__, getDebugNode, indexDebugNode, removeDebugNodeFromIndex} from '../debug/debug_node';
1010
import {Injector} from '../di';
1111
import {InjectableType} from '../di/injectable';
1212
import {getInjectableDef, ɵɵInjectableDef} from '../di/interface/defs';
@@ -827,7 +827,7 @@ export class DebugRenderer2 implements Renderer2 {
827827
if (typeof target !== 'string') {
828828
const debugEl = getDebugNode(target);
829829
if (debugEl) {
830-
debugEl.listeners.push(new EventListener(eventName, callback));
830+
debugEl.listeners.push(new DebugEventListener(eventName, callback));
831831
}
832832
}
833833

‎tools/public_api_guard/core/core.d.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,17 @@ export declare const DebugElement: {
224224
new (...args: any[]): DebugElement;
225225
};
226226

227+
export declare class DebugEventListener {
228+
callback: Function;
229+
name: string;
230+
constructor(name: string, callback: Function);
231+
}
232+
227233
export interface DebugNode {
228234
readonly componentInstance: any;
229235
readonly context: any;
230236
readonly injector: Injector;
231-
readonly listeners: EventListener[];
237+
readonly listeners: DebugEventListener[];
232238
readonly nativeNode: any;
233239
readonly parent: DebugElement | null;
234240
readonly providerTokens: any[];

0 commit comments

Comments
 (0)
Please sign in to comment.