diff --git a/packages/core/src/core.externs.js b/packages/core/src/core.externs.js new file mode 100644 index 0000000000..8ee983fc7e --- /dev/null +++ b/packages/core/src/core.externs.js @@ -0,0 +1,18 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + * + * @externs + */ + +/** + * @suppress {duplicate} + */ +var ng; +/** + * @suppress {duplicate} + */ +var wtf; diff --git a/packages/core/src/util.ts b/packages/core/src/util.ts index 393cf40488..1b1d088258 100644 --- a/packages/core/src/util.ts +++ b/packages/core/src/util.ts @@ -21,6 +21,11 @@ const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'unde self instanceof WorkerGlobalScope && self; const __global = typeof global !== 'undefined' && global; const _global: {[name: string]: any} = __window || __global || __self; +/** + * Attention: whenever providing a new value, be sure to add an + * entry into the corresponding `....externs.js` file, + * so that closure won't use that global for its purposes. + */ export {_global as global}; // When Symbol.iterator doesn't exist, retrieves the key used in es6-shim diff --git a/packages/platform-browser/src/dom/events/dom_events.ts b/packages/platform-browser/src/dom/events/dom_events.ts index 906fb52b2a..a80ea82bb2 100644 --- a/packages/platform-browser/src/dom/events/dom_events.ts +++ b/packages/platform-browser/src/dom/events/dom_events.ts @@ -6,7 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {Inject, Injectable, NgZone, ɵglobal as global} from '@angular/core'; +import {Inject, Injectable, NgZone} from '@angular/core'; +// Import zero symbols from zone.js. This causes the zone ambient type to be +// added to the type-checker, without emitting any runtime module load statement +import {} from 'zone.js'; import {DOCUMENT} from '../dom_tokens'; @@ -18,8 +21,8 @@ import {EventManagerPlugin} from './event_manager'; * efficient bookkeeping than Zone can, because we have additional information. This speeds up * addEventListener by 3x. */ -const Zone = global['Zone']; -const __symbol__ = Zone && Zone['__symbol__'] || function(v: T): T { +const __symbol__ = + (typeof Zone !== 'undefined') && (Zone as any)['__symbol__'] || function(v: T): T { return v; }; const ADD_EVENT_LISTENER: 'addEventListener' = __symbol__('addEventListener'); @@ -32,7 +35,8 @@ const ANGULAR = 'ANGULAR'; const NATIVE_ADD_LISTENER = 'addEventListener'; const NATIVE_REMOVE_LISTENER = 'removeEventListener'; -const blackListedEvents: string[] = Zone && Zone[__symbol__('BLACK_LISTED_EVENTS')]; +const blackListedEvents: string[] = + (typeof Zone !== 'undefined') && (Zone as any)[__symbol__('BLACK_LISTED_EVENTS')]; let blackListedMap: {[eventName: string]: string}; if (blackListedEvents) { blackListedMap = {}; diff --git a/packages/platform-browser/src/platform-browser.externs.js b/packages/platform-browser/src/platform-browser.externs.js new file mode 100644 index 0000000000..41ad83accb --- /dev/null +++ b/packages/platform-browser/src/platform-browser.externs.js @@ -0,0 +1,26 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + * + * @externs + */ + +/** + * @suppress {duplicate} + */ +var getAngularTestability; +/** + * @suppress {duplicate} + */ +var getAllAngularTestabilities; +/** + * @suppress {duplicate} + */ +var getAllAngularRootElements; +/** + * @suppress {duplicate} + */ +var frameworkStabilizers;