fix(typings): Don't expose typing dependencies to users.
This resolves Duplicate Identifier issues seen by many users, at the expense of more typings installation required in some cases. Removes the quickstart hack of placing all needed dependencies typings files in our distribution. Removes dependencies on nodejs from angular2/core. Fixes #5973 Fixes #5807 Fixes #6266 Angular now depends on es6-promise and es6-collections (and a handful of manual typings) rather than all of es6-shim. Fixes #5242 We previously had an undocumented breaking change, this is now documented in this commit. Fixes #6817 BREAKING CHANGE: Transitive typings are no longer included in the distribution. You may need to install typings in your project using http://github.com/typings/typings Users now must rely on getting typings from: - one of the peerDependencies, such as rxjs, which exposes typings via the moduleResolution=node mechanism. (see https://github.com/Microsoft/TypeScript/wiki/Typings-for-npm-packages) This happens automatically. - Using --target ES5 now requires manual installation of es6-promise and es6-collections typings. - Using some angular APIs may introduce a dependency on eg. nodejs or jasmine, and those typings need manual installation as well. Closes #6267
This commit is contained in:
@ -248,15 +248,12 @@ class _Scanner {
|
||||
}
|
||||
|
||||
scanCharacter(start: number, code: number): Token {
|
||||
assert(this.peek == code);
|
||||
this.advance();
|
||||
return newCharacterToken(start, code);
|
||||
}
|
||||
|
||||
|
||||
scanOperator(start: number, str: string): Token {
|
||||
assert(this.peek == StringWrapper.charCodeAt(str, 0));
|
||||
assert(SetWrapper.has(OPERATORS, str));
|
||||
this.advance();
|
||||
return newOperatorToken(start, str);
|
||||
}
|
||||
@ -274,7 +271,6 @@ class _Scanner {
|
||||
*/
|
||||
scanComplexOperator(start: number, one: string, twoCode: number, two: string, threeCode?: number,
|
||||
three?: string): Token {
|
||||
assert(this.peek == StringWrapper.charCodeAt(one, 0));
|
||||
this.advance();
|
||||
var str: string = one;
|
||||
if (this.peek == twoCode) {
|
||||
@ -285,12 +281,10 @@ class _Scanner {
|
||||
this.advance();
|
||||
str += three;
|
||||
}
|
||||
assert(SetWrapper.has(OPERATORS, str));
|
||||
return newOperatorToken(start, str);
|
||||
}
|
||||
|
||||
scanIdentifier(): Token {
|
||||
assert(isIdentifierStart(this.peek));
|
||||
var start: number = this.index;
|
||||
this.advance();
|
||||
while (isIdentifierPart(this.peek)) this.advance();
|
||||
@ -303,7 +297,6 @@ class _Scanner {
|
||||
}
|
||||
|
||||
scanNumber(start: number): Token {
|
||||
assert(isDigit(this.peek));
|
||||
var simple: boolean = (this.index === start);
|
||||
this.advance(); // Skip initial digit.
|
||||
while (true) {
|
||||
@ -329,7 +322,6 @@ class _Scanner {
|
||||
}
|
||||
|
||||
scanString(): Token {
|
||||
assert(this.peek == $SQ || this.peek == $DQ);
|
||||
var start: number = this.index;
|
||||
var quote: number = this.peek;
|
||||
this.advance(); // Skip initial quote.
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
import {normalizeBlank, isPresent, global} from 'angular2/src/facade/lang';
|
||||
import {normalizeBlank, isPresent, global, ZoneLike} from 'angular2/src/facade/lang';
|
||||
import {ObservableWrapper, EventEmitter} from 'angular2/src/facade/async';
|
||||
import {wtfLeave, wtfCreateScope, WtfScopeFn} from '../profile/profile';
|
||||
|
||||
export interface NgZoneZone extends Zone {
|
||||
export interface NgZoneZone extends ZoneLike {
|
||||
/** @internal */
|
||||
_innerZone: boolean;
|
||||
}
|
||||
@ -348,8 +348,9 @@ export class NgZone {
|
||||
var errorHandling;
|
||||
|
||||
if (enableLongStackTrace) {
|
||||
errorHandling = StringMapWrapper.merge(
|
||||
Zone.longStackTraceZone, {onError: function(e) { ngZone._notifyOnError(this, e); }});
|
||||
errorHandling =
|
||||
StringMapWrapper.merge(global.Zone.longStackTraceZone,
|
||||
{onError: function(e) { ngZone._notifyOnError(this, e); }});
|
||||
} else {
|
||||
errorHandling = {onError: function(e) { ngZone._notifyOnError(this, e); }};
|
||||
}
|
||||
|
@ -15,20 +15,16 @@ import {toPromise} from 'rxjs/operator/toPromise';
|
||||
export {Observable} from 'rxjs/Observable';
|
||||
export {Subject} from 'rxjs/Subject';
|
||||
|
||||
export namespace NodeJS {
|
||||
export interface Timer {}
|
||||
}
|
||||
|
||||
export class TimerWrapper {
|
||||
static setTimeout(fn: (...args: any[]) => void, millis: number): NodeJS.Timer {
|
||||
static setTimeout(fn: (...args: any[]) => void, millis: number): number {
|
||||
return global.setTimeout(fn, millis);
|
||||
}
|
||||
static clearTimeout(id: NodeJS.Timer): void { global.clearTimeout(id); }
|
||||
static clearTimeout(id: number): void { global.clearTimeout(id); }
|
||||
|
||||
static setInterval(fn: (...args: any[]) => void, millis: number): NodeJS.Timer {
|
||||
static setInterval(fn: (...args: any[]) => void, millis: number): number {
|
||||
return global.setInterval(fn, millis);
|
||||
}
|
||||
static clearInterval(id: NodeJS.Timer): void { global.clearInterval(id); }
|
||||
static clearInterval(id: number): void { global.clearInterval(id); }
|
||||
}
|
||||
|
||||
export class ObservableWrapper {
|
||||
@ -161,4 +157,4 @@ export class EventEmitter<T> extends Subject<T> {
|
||||
|
||||
return super.subscribe(schedulerFn, errorFn, completeFn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,36 @@
|
||||
// Zones are TC-39 standards-track so users could choose a different implementation
|
||||
// Rather than import {Zone} from 'zone.js' we define an interface
|
||||
// so that any library that structurally matches may be used with Angular 2.
|
||||
export interface ZoneLike {
|
||||
fork(locals?: any): ZoneLike;
|
||||
run(fn: any, applyTo?: any, applyWith?: any): any;
|
||||
}
|
||||
export interface ZoneLikeConstructor {
|
||||
longStackTraceZone: { [key: string]: any; };
|
||||
}
|
||||
|
||||
export interface BrowserNodeGlobal {
|
||||
Object: typeof Object;
|
||||
Array: typeof Array;
|
||||
Map: typeof Map;
|
||||
Set: typeof Set;
|
||||
Date: DateConstructor;
|
||||
RegExp: RegExpConstructor;
|
||||
JSON: typeof JSON;
|
||||
Math: any; // typeof Math;
|
||||
assert(condition: any): void;
|
||||
Reflect: any;
|
||||
zone: ZoneLike;
|
||||
Zone: ZoneLikeConstructor;
|
||||
getAngularTestability: Function;
|
||||
getAllAngularTestabilities: Function;
|
||||
frameworkStabilizers: Array<Function>;
|
||||
setTimeout: Function;
|
||||
clearTimeout: Function;
|
||||
setInterval: Function;
|
||||
clearInterval: Function;
|
||||
}
|
||||
|
||||
// TODO(jteplitz602): Load WorkerGlobalScope from lib.webworker.d.ts file #3492
|
||||
declare var WorkerGlobalScope;
|
||||
var globalScope: BrowserNodeGlobal;
|
||||
@ -10,7 +43,7 @@ if (typeof window === 'undefined') {
|
||||
}
|
||||
} else {
|
||||
globalScope = <any>window;
|
||||
};
|
||||
}
|
||||
|
||||
export const IS_DART = false;
|
||||
|
||||
@ -430,4 +463,4 @@ export function evalExpression(sourceUrl: string, expr: string, declarations: st
|
||||
|
||||
export function isPrimitive(obj: any): boolean {
|
||||
return !isJsObject(obj);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user