diff --git a/packages/platform-browser/src/browser/browser_adapter.ts b/packages/platform-browser/src/browser/browser_adapter.ts index d40cf891eb..5747047fbb 100644 --- a/packages/platform-browser/src/browser/browser_adapter.ts +++ b/packages/platform-browser/src/browser/browser_adapter.ts @@ -63,9 +63,9 @@ const _chromeNumKeyPadMap = { '\x90': 'NumLock' }; -const nodeContains: (a: any, b: any) => boolean = (() => { +const nodeContains: (this: Node, other: Node) => boolean = (() => { if (global['Node']) { - return global['Node'].prototype.contains || function(node: any) { + return global['Node'].prototype.contains || function(this: Node, node: any) { return !!(this.compareDocumentPosition(node) & 16); }; } diff --git a/packages/platform-browser/src/dom/events/dom_events.ts b/packages/platform-browser/src/dom/events/dom_events.ts index 2d3045eb15..051a63d339 100644 --- a/packages/platform-browser/src/dom/events/dom_events.ts +++ b/packages/platform-browser/src/dom/events/dom_events.ts @@ -61,7 +61,7 @@ interface TaskData { // a global listener to handle all dom event, // so we do not need to create a closure every time -const globalListener = function(event: Event) { +const globalListener = function(this: any, event: Event) { const symbolName = symbolNames[event.type]; if (!symbolName) { return; @@ -123,15 +123,17 @@ export class DomEventsPlugin extends EventManagerPlugin { } const delegate = (Event.prototype as any)[stopMethodSymbol] = Event.prototype.stopImmediatePropagation; - Event.prototype.stopImmediatePropagation = function() { + Event.prototype.stopImmediatePropagation = function(this: any) { if (this) { this[stopSymbol] = true; } - // should call native delegate in case - // in some environment part of the application - // will not use the patched Event - delegate && delegate.apply(this, arguments); + // We should call native delegate in case in some environment part of + // the application will not use the patched Event. Also we cast the + // "arguments" to any since "stopImmediatePropagation" technically does not + // accept any arguments, but we don't know what developers pass through the + // function and we want to not break these calls. + delegate && delegate.apply(this, arguments as any); }; }