fix: add types for ts2dart's façade handling.

... in many, many places.
This commit is contained in:
Martin Probst 2015-06-11 18:50:41 -07:00
parent c4ecbf0a7f
commit f3d741854a
34 changed files with 259 additions and 213 deletions

View File

@ -1,5 +1,6 @@
import {isPresent, isBlank, BaseException, FunctionWrapper} from 'angular2/src/facade/lang'; import {isPresent, isBlank, BaseException, FunctionWrapper} from 'angular2/src/facade/lang';
import {List, ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/facade/collection'; import {List, ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
import {Locals} from 'angular2/src/change_detection/parser/locals';
import {AbstractChangeDetector} from './abstract_change_detector'; import {AbstractChangeDetector} from './abstract_change_detector';
import {BindingRecord} from './binding_record'; import {BindingRecord} from './binding_record';
@ -12,7 +13,7 @@ import {ProtoRecord, RecordType} from './proto_record';
import {ExpressionChangedAfterItHasBeenChecked, ChangeDetectionError} from './exceptions'; import {ExpressionChangedAfterItHasBeenChecked, ChangeDetectionError} from './exceptions';
export class DynamicChangeDetector extends AbstractChangeDetector { export class DynamicChangeDetector extends AbstractChangeDetector {
locals: any = null; locals: Locals = null;
values: List<any>; values: List<any>;
changes: List<any>; changes: List<any>;
pipes: List<any>; pipes: List<any>;
@ -36,7 +37,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
ListWrapper.fill(this.changes, false); ListWrapper.fill(this.changes, false);
} }
hydrate(context: any, locals: any, directives: any) { hydrate(context: any, locals: Locals, directives: any) {
this.mode = ChangeDetectionUtil.changeDetectionMode(this.changeControlStrategy); this.mode = ChangeDetectionUtil.changeDetectionMode(this.changeControlStrategy);
this.values[0] = context; this.values[0] = context;
this.locals = locals; this.locals = locals;

View File

@ -1,12 +1,13 @@
import {isBlank, isPresent, FunctionWrapper, BaseException} from "angular2/src/facade/lang"; import {isBlank, isPresent, FunctionWrapper, BaseException} from "angular2/src/facade/lang";
import {List, Map, ListWrapper, StringMapWrapper} from "angular2/src/facade/collection"; import {List, Map, ListWrapper, StringMapWrapper} from "angular2/src/facade/collection";
import {Locals} from "./locals";
export class AST { export class AST {
eval(context, locals) { throw new BaseException("Not supported"); } eval(context, locals: Locals) { throw new BaseException("Not supported"); }
get isAssignable(): boolean { return false; } get isAssignable(): boolean { return false; }
assign(context, locals, value) { throw new BaseException("Not supported"); } assign(context, locals: Locals, value) { throw new BaseException("Not supported"); }
visit(visitor: AstVisitor): any { return null; } visit(visitor: AstVisitor): any { return null; }
@ -14,7 +15,7 @@ export class AST {
} }
export class EmptyExpr extends AST { export class EmptyExpr extends AST {
eval(context, locals) { return null; } eval(context, locals: Locals) { return null; }
visit(visitor: AstVisitor) { visit(visitor: AstVisitor) {
// do nothing // do nothing
@ -22,7 +23,7 @@ export class EmptyExpr extends AST {
} }
export class ImplicitReceiver extends AST { export class ImplicitReceiver extends AST {
eval(context, locals) { return context; } eval(context, locals: Locals) { return context; }
visit(visitor: AstVisitor) { return visitor.visitImplicitReceiver(this); } visit(visitor: AstVisitor) { return visitor.visitImplicitReceiver(this); }
} }
@ -33,7 +34,7 @@ export class ImplicitReceiver extends AST {
export class Chain extends AST { export class Chain extends AST {
constructor(public expressions: List<any>) { super(); } constructor(public expressions: List<any>) { super(); }
eval(context, locals) { eval(context, locals: Locals) {
var result; var result;
for (var i = 0; i < this.expressions.length; i++) { for (var i = 0; i < this.expressions.length; i++) {
var last = this.expressions[i].eval(context, locals); var last = this.expressions[i].eval(context, locals);
@ -48,7 +49,7 @@ export class Chain extends AST {
export class Conditional extends AST { export class Conditional extends AST {
constructor(public condition: AST, public trueExp: AST, public falseExp: AST) { super(); } constructor(public condition: AST, public trueExp: AST, public falseExp: AST) { super(); }
eval(context, locals) { eval(context, locals: Locals) {
if (this.condition.eval(context, locals)) { if (this.condition.eval(context, locals)) {
return this.trueExp.eval(context, locals); return this.trueExp.eval(context, locals);
} else { } else {
@ -65,7 +66,7 @@ export class AccessMember extends AST {
super(); super();
} }
eval(context, locals) { eval(context, locals: Locals) {
if (this.receiver instanceof ImplicitReceiver && isPresent(locals) && if (this.receiver instanceof ImplicitReceiver && isPresent(locals) &&
locals.contains(this.name)) { locals.contains(this.name)) {
return locals.get(this.name); return locals.get(this.name);
@ -77,7 +78,7 @@ export class AccessMember extends AST {
get isAssignable(): boolean { return true; } get isAssignable(): boolean { return true; }
assign(context, locals, value) { assign(context, locals: Locals, value) {
var evaluatedContext = this.receiver.eval(context, locals); var evaluatedContext = this.receiver.eval(context, locals);
if (this.receiver instanceof ImplicitReceiver && isPresent(locals) && if (this.receiver instanceof ImplicitReceiver && isPresent(locals) &&
@ -97,7 +98,7 @@ export class SafeAccessMember extends AST {
super(); super();
} }
eval(context, locals) { eval(context, locals: Locals) {
var evaluatedReceiver = this.receiver.eval(context, locals); var evaluatedReceiver = this.receiver.eval(context, locals);
return isBlank(evaluatedReceiver) ? null : this.getter(evaluatedReceiver); return isBlank(evaluatedReceiver) ? null : this.getter(evaluatedReceiver);
} }
@ -108,7 +109,7 @@ export class SafeAccessMember extends AST {
export class KeyedAccess extends AST { export class KeyedAccess extends AST {
constructor(public obj: AST, public key: AST) { super(); } constructor(public obj: AST, public key: AST) { super(); }
eval(context, locals) { eval(context, locals: Locals) {
var obj: any = this.obj.eval(context, locals); var obj: any = this.obj.eval(context, locals);
var key: any = this.key.eval(context, locals); var key: any = this.key.eval(context, locals);
return obj[key]; return obj[key];
@ -116,7 +117,7 @@ export class KeyedAccess extends AST {
get isAssignable(): boolean { return true; } get isAssignable(): boolean { return true; }
assign(context, locals, value) { assign(context, locals: Locals, value) {
var obj: any = this.obj.eval(context, locals); var obj: any = this.obj.eval(context, locals);
var key: any = this.key.eval(context, locals); var key: any = this.key.eval(context, locals);
obj[key] = value; obj[key] = value;
@ -138,7 +139,7 @@ export class Pipe extends AST {
export class LiteralPrimitive extends AST { export class LiteralPrimitive extends AST {
constructor(public value) { super(); } constructor(public value) { super(); }
eval(context, locals) { return this.value; } eval(context, locals: Locals) { return this.value; }
visit(visitor: AstVisitor) { return visitor.visitLiteralPrimitive(this); } visit(visitor: AstVisitor) { return visitor.visitLiteralPrimitive(this); }
} }
@ -146,7 +147,7 @@ export class LiteralPrimitive extends AST {
export class LiteralArray extends AST { export class LiteralArray extends AST {
constructor(public expressions: List<any>) { super(); } constructor(public expressions: List<any>) { super(); }
eval(context, locals) { eval(context, locals: Locals) {
return ListWrapper.map(this.expressions, (e) => e.eval(context, locals)); return ListWrapper.map(this.expressions, (e) => e.eval(context, locals));
} }
@ -156,7 +157,7 @@ export class LiteralArray extends AST {
export class LiteralMap extends AST { export class LiteralMap extends AST {
constructor(public keys: List<any>, public values: List<any>) { super(); } constructor(public keys: List<any>, public values: List<any>) { super(); }
eval(context, locals) { eval(context, locals: Locals) {
var res = StringMapWrapper.create(); var res = StringMapWrapper.create();
for (var i = 0; i < this.keys.length; ++i) { for (var i = 0; i < this.keys.length; ++i) {
StringMapWrapper.set(res, this.keys[i], this.values[i].eval(context, locals)); StringMapWrapper.set(res, this.keys[i], this.values[i].eval(context, locals));
@ -178,7 +179,7 @@ export class Interpolation extends AST {
export class Binary extends AST { export class Binary extends AST {
constructor(public operation: string, public left: AST, public right: AST) { super(); } constructor(public operation: string, public left: AST, public right: AST) { super(); }
eval(context, locals) { eval(context, locals: Locals) {
var left: any = this.left.eval(context, locals); var left: any = this.left.eval(context, locals);
switch (this.operation) { switch (this.operation) {
case '&&': case '&&':
@ -229,7 +230,7 @@ export class Binary extends AST {
export class PrefixNot extends AST { export class PrefixNot extends AST {
constructor(public expression: AST) { super(); } constructor(public expression: AST) { super(); }
eval(context, locals) { return !this.expression.eval(context, locals); } eval(context, locals: Locals) { return !this.expression.eval(context, locals); }
visit(visitor: AstVisitor) { return visitor.visitPrefixNot(this); } visit(visitor: AstVisitor) { return visitor.visitPrefixNot(this); }
} }
@ -237,7 +238,7 @@ export class PrefixNot extends AST {
export class Assignment extends AST { export class Assignment extends AST {
constructor(public target: AST, public value: AST) { super(); } constructor(public target: AST, public value: AST) { super(); }
eval(context, locals) { eval(context, locals: Locals) {
return this.target.assign(context, locals, this.value.eval(context, locals)); return this.target.assign(context, locals, this.value.eval(context, locals));
} }
@ -250,7 +251,7 @@ export class MethodCall extends AST {
super(); super();
} }
eval(context, locals) { eval(context, locals: Locals) {
var evaluatedArgs = evalList(context, locals, this.args); var evaluatedArgs = evalList(context, locals, this.args);
if (this.receiver instanceof ImplicitReceiver && isPresent(locals) && if (this.receiver instanceof ImplicitReceiver && isPresent(locals) &&
locals.contains(this.name)) { locals.contains(this.name)) {
@ -271,7 +272,7 @@ export class SafeMethodCall extends AST {
super(); super();
} }
eval(context, locals) { eval(context, locals: Locals) {
var evaluatedReceiver = this.receiver.eval(context, locals); var evaluatedReceiver = this.receiver.eval(context, locals);
if (isBlank(evaluatedReceiver)) return null; if (isBlank(evaluatedReceiver)) return null;
var evaluatedArgs = evalList(context, locals, this.args); var evaluatedArgs = evalList(context, locals, this.args);
@ -284,7 +285,7 @@ export class SafeMethodCall extends AST {
export class FunctionCall extends AST { export class FunctionCall extends AST {
constructor(public target: AST, public args: List<any>) { super(); } constructor(public target: AST, public args: List<any>) { super(); }
eval(context, locals) { eval(context, locals: Locals) {
var obj: any = this.target.eval(context, locals); var obj: any = this.target.eval(context, locals);
if (!(obj instanceof Function)) { if (!(obj instanceof Function)) {
throw new BaseException(`${obj} is not a function`); throw new BaseException(`${obj} is not a function`);
@ -298,11 +299,11 @@ export class FunctionCall extends AST {
export class ASTWithSource extends AST { export class ASTWithSource extends AST {
constructor(public ast: AST, public source: string, public location: string) { super(); } constructor(public ast: AST, public source: string, public location: string) { super(); }
eval(context, locals) { return this.ast.eval(context, locals); } eval(context, locals: Locals) { return this.ast.eval(context, locals); }
get isAssignable(): boolean { return this.ast.isAssignable; } get isAssignable(): boolean { return this.ast.isAssignable; }
assign(context, locals, value) { return this.ast.assign(context, locals, value); } assign(context, locals: Locals, value) { return this.ast.assign(context, locals, value); }
visit(visitor: AstVisitor) { return this.ast.visit(visitor); } visit(visitor: AstVisitor) { return this.ast.visit(visitor); }
@ -413,7 +414,7 @@ var _evalListCache = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]; ];
function evalList(context, locals, exps: List<any>) { function evalList(context, locals: Locals, exps: List<any>) {
var length = exps.length; var length = exps.length;
if (length > 10) { if (length > 10) {
throw new BaseException("Cannot have more than 10 argument"); throw new BaseException("Cannot have more than 10 argument");

View File

@ -609,7 +609,7 @@ class _DuplicateItemRecordList {
} }
class _DuplicateMap { class _DuplicateMap {
map: Map<any, any>; map: Map<any, _DuplicateItemRecordList>;
constructor() { this.map = MapWrapper.create(); } constructor() { this.map = MapWrapper.create(); }
put(record: CollectionChangeRecord) { put(record: CollectionChangeRecord) {

View File

@ -150,7 +150,7 @@ export class TreeNode<T extends TreeNode<any>> {
get parent() { return this._parent; } get parent() { return this._parent; }
// TODO(rado): replace with a function call, does too much work for a getter. // TODO(rado): replace with a function call, does too much work for a getter.
get children() { get children(): TreeNode<any>[] {
var res = []; var res = [];
var child = this._head; var child = this._head;
while (child != null) { while (child != null) {

View File

@ -9,8 +9,7 @@ import {NgControl} from './ng_control';
import {Control} from '../model'; import {Control} from '../model';
import {setUpControl} from './shared'; import {setUpControl} from './shared';
const formControlBinding = const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRef(() => NgModel)}));
CONST_EXPR(new Binding(NgControl, {toAlias: forwardRef(() => NgModel)}));
/** /**
* Binds a domain model to the form. * Binds a domain model to the form.

View File

@ -1,4 +1,4 @@
/// <reference path="../../../../typings/hammerjs/hammerjs"/> /// <reference path="../../../../typings/hammerjs/hammerjs.d.ts"/>
import {HammerGesturesPluginCommon} from './hammer_common'; import {HammerGesturesPluginCommon} from './hammer_common';
import {isPresent, BaseException} from 'angular2/src/facade/lang'; import {isPresent, BaseException} from 'angular2/src/facade/lang';

View File

@ -90,8 +90,8 @@ export class Router {
*/ */
config(config: any): Promise<any> { config(config: any): Promise<any> {
if (config instanceof List) { if (config instanceof List) {
config.forEach( (<List<any>>config)
(configObject) => { this._registry.config(this.hostComponent, configObject); }); .forEach((configObject) => { this._registry.config(this.hostComponent, configObject); });
} else { } else {
this._registry.config(this.hostComponent, config); this._registry.config(this.hostComponent, config);
} }

View File

@ -128,7 +128,7 @@ export class ViewProxy {
this._view.changeDetector.checkNoChanges(); this._view.changeDetector.checkNoChanges();
} }
querySelector(selector) { return queryView(this._view, selector); } querySelector(selector): any { return queryView(this._view, selector); }
destroy() { this._componentRef.dispose(); } destroy() { this._componentRef.dispose(); }

View File

@ -23,7 +23,7 @@ export function viewRootNodes(view): List</*node*/ any> {
return resolveInternalDomView(view.render).rootNodes; return resolveInternalDomView(view.render).rootNodes;
} }
export function queryView(view, selector: string) { export function queryView(view, selector: string): any {
var rootNodes = viewRootNodes(view); var rootNodes = viewRootNodes(view);
for (var i = 0; i < rootNodes.length; ++i) { for (var i = 0; i < rootNodes.length; ++i) {
var res = DOM.querySelector(rootNodes[i], selector); var res = DOM.querySelector(rootNodes[i], selector);

View File

@ -6,7 +6,7 @@ import {MapWrapper} from 'angular2/src/facade/collection';
export function main() { export function main() {
describe('Locals', () => { describe('Locals', () => {
var locals; var locals: Locals;
beforeEach(() => { beforeEach(() => {
locals = new Locals(null, MapWrapper.createFromPairs([['key', 'value'], ['nullKey', null]])); locals = new Locals(null, MapWrapper.createFromPairs([['key', 'value'], ['nullKey', null]]));
}); });

View File

@ -12,7 +12,6 @@ export function main() {
describe('collection_changes', function() { describe('collection_changes', function() {
describe('CollectionChanges', function() { describe('CollectionChanges', function() {
var changes; var changes;
var l;
beforeEach(() => { changes = new IterableChanges(); }); beforeEach(() => { changes = new IterableChanges(); });
@ -26,7 +25,7 @@ export function main() {
}); });
it('should support iterables', () => { it('should support iterables', () => {
l = new TestIterable(); let l = new TestIterable();
changes.check(l); changes.check(l);
expect(changes.toString()).toEqual(iterableChangesAsString({collection: []})); expect(changes.toString()).toEqual(iterableChangesAsString({collection: []}));
@ -49,17 +48,17 @@ export function main() {
}); });
it('should detect additions', () => { it('should detect additions', () => {
l = []; let l = [];
changes.check(l); changes.check(l);
expect(changes.toString()).toEqual(iterableChangesAsString({collection: []})); expect(changes.toString()).toEqual(iterableChangesAsString({collection: []}));
ListWrapper.push(l, 'a'); l.push('a');
changes.check(l); changes.check(l);
expect(changes.toString()) expect(changes.toString())
.toEqual( .toEqual(
iterableChangesAsString({collection: ['a[null->0]'], additions: ['a[null->0]']})); iterableChangesAsString({collection: ['a[null->0]'], additions: ['a[null->0]']}));
ListWrapper.push(l, 'b'); l.push('b');
changes.check(l); changes.check(l);
expect(changes.toString()) expect(changes.toString())
.toEqual(iterableChangesAsString( .toEqual(iterableChangesAsString(
@ -67,7 +66,7 @@ export function main() {
}); });
it('should support changing the reference', () => { it('should support changing the reference', () => {
l = [0]; let l = [0];
changes.check(l); changes.check(l);
l = [1, 0]; l = [1, 0];
@ -92,12 +91,12 @@ export function main() {
}); });
it('should handle swapping element', () => { it('should handle swapping element', () => {
l = [1, 2]; let l = [1, 2];
changes.check(l); changes.check(l);
ListWrapper.clear(l); ListWrapper.clear(l);
ListWrapper.push(l, 2); l.push(2);
ListWrapper.push(l, 1); l.push(1);
changes.check(l); changes.check(l);
expect(changes.toString()) expect(changes.toString())
.toEqual(iterableChangesAsString({ .toEqual(iterableChangesAsString({
@ -108,7 +107,7 @@ export function main() {
}); });
it('should handle swapping element', () => { it('should handle swapping element', () => {
l = ['a', 'b', 'c']; let l = ['a', 'b', 'c'];
changes.check(l); changes.check(l);
ListWrapper.removeAt(l, 1); ListWrapper.removeAt(l, 1);
@ -122,7 +121,7 @@ export function main() {
})); }));
ListWrapper.removeAt(l, 1); ListWrapper.removeAt(l, 1);
ListWrapper.push(l, 'a'); l.push('a');
changes.check(l); changes.check(l);
expect(changes.toString()) expect(changes.toString())
.toEqual(iterableChangesAsString({ .toEqual(iterableChangesAsString({
@ -133,23 +132,23 @@ export function main() {
}); });
it('should detect changes in list', () => { it('should detect changes in list', () => {
l = []; let l = [];
changes.check(l); changes.check(l);
ListWrapper.push(l, 'a'); l.push('a');
changes.check(l); changes.check(l);
expect(changes.toString()) expect(changes.toString())
.toEqual( .toEqual(
iterableChangesAsString({collection: ['a[null->0]'], additions: ['a[null->0]']})); iterableChangesAsString({collection: ['a[null->0]'], additions: ['a[null->0]']}));
ListWrapper.push(l, 'b'); l.push('b');
changes.check(l); changes.check(l);
expect(changes.toString()) expect(changes.toString())
.toEqual(iterableChangesAsString( .toEqual(iterableChangesAsString(
{collection: ['a', 'b[null->1]'], previous: ['a'], additions: ['b[null->1]']})); {collection: ['a', 'b[null->1]'], previous: ['a'], additions: ['b[null->1]']}));
ListWrapper.push(l, 'c'); l.push('c');
ListWrapper.push(l, 'd'); l.push('d');
changes.check(l); changes.check(l);
expect(changes.toString()) expect(changes.toString())
.toEqual(iterableChangesAsString({ .toEqual(iterableChangesAsString({
@ -169,10 +168,10 @@ export function main() {
})); }));
ListWrapper.clear(l); ListWrapper.clear(l);
ListWrapper.push(l, 'd'); l.push('d');
ListWrapper.push(l, 'c'); l.push('c');
ListWrapper.push(l, 'b'); l.push('b');
ListWrapper.push(l, 'a'); l.push('a');
changes.check(l); changes.check(l);
expect(changes.toString()) expect(changes.toString())
.toEqual(iterableChangesAsString({ .toEqual(iterableChangesAsString({
@ -184,7 +183,7 @@ export function main() {
}); });
it('should test string by value rather than by reference (Dart)', () => { it('should test string by value rather than by reference (Dart)', () => {
l = ['a', 'boo']; let l = ['a', 'boo'];
changes.check(l); changes.check(l);
var b = 'b'; var b = 'b';
@ -196,7 +195,7 @@ export function main() {
}); });
it('should ignore [NaN] != [NaN] (JS)', () => { it('should ignore [NaN] != [NaN] (JS)', () => {
l = [NumberWrapper.NaN]; let l = [NumberWrapper.NaN];
changes.check(l); changes.check(l);
changes.check(l); changes.check(l);
expect(changes.toString()) expect(changes.toString())
@ -205,7 +204,7 @@ export function main() {
}); });
it('should detect [NaN] moves', () => { it('should detect [NaN] moves', () => {
l = [NumberWrapper.NaN, NumberWrapper.NaN]; let l = [NumberWrapper.NaN, NumberWrapper.NaN];
changes.check(l); changes.check(l);
ListWrapper.insert(l, 0, 'foo'); ListWrapper.insert(l, 0, 'foo');
@ -220,7 +219,7 @@ export function main() {
}); });
it('should remove and add same item', () => { it('should remove and add same item', () => {
l = ['a', 'b', 'c']; let l = ['a', 'b', 'c'];
changes.check(l); changes.check(l);
ListWrapper.removeAt(l, 1); ListWrapper.removeAt(l, 1);
@ -245,7 +244,7 @@ export function main() {
}); });
it('should support duplicates', () => { it('should support duplicates', () => {
l = ['a', 'a', 'a', 'b', 'b']; let l = ['a', 'a', 'a', 'b', 'b'];
changes.check(l); changes.check(l);
ListWrapper.removeAt(l, 0); ListWrapper.removeAt(l, 0);
@ -260,7 +259,7 @@ export function main() {
}); });
it('should support insertions/moves', () => { it('should support insertions/moves', () => {
l = ['a', 'a', 'b', 'b']; let l = ['a', 'a', 'b', 'b'];
changes.check(l); changes.check(l);
ListWrapper.insert(l, 0, 'b'); ListWrapper.insert(l, 0, 'b');
@ -275,13 +274,13 @@ export function main() {
}); });
it('should not report unnecessary moves', () => { it('should not report unnecessary moves', () => {
l = ['a', 'b', 'c']; let l = ['a', 'b', 'c'];
changes.check(l); changes.check(l);
ListWrapper.clear(l); ListWrapper.clear(l);
ListWrapper.push(l, 'b'); l.push('b');
ListWrapper.push(l, 'a'); l.push('a');
ListWrapper.push(l, 'c'); l.push('c');
changes.check(l); changes.check(l);
expect(changes.toString()) expect(changes.toString())
.toEqual(iterableChangesAsString({ .toEqual(iterableChangesAsString({

View File

@ -16,7 +16,7 @@ import {bootstrap} from 'angular2/src/core/application';
import {Component, Directive, View} from 'angular2/annotations'; import {Component, Directive, View} from 'angular2/annotations';
import {DOM} from 'angular2/src/dom/dom_adapter'; import {DOM} from 'angular2/src/dom/dom_adapter';
import {PromiseWrapper} from 'angular2/src/facade/async'; import {PromiseWrapper} from 'angular2/src/facade/async';
import {bind, Inject} from 'angular2/di'; import {bind, Inject, Injector} from 'angular2/di';
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability'; import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
import {DOCUMENT_TOKEN} from 'angular2/src/render/dom/dom_renderer'; import {DOCUMENT_TOKEN} from 'angular2/src/render/dom/dom_renderer';
@ -181,7 +181,7 @@ export function main() {
PromiseWrapper.all([refPromise1, refPromise2]) PromiseWrapper.all([refPromise1, refPromise2])
.then((refs) => { .then((refs) => {
var registry = refs[0].injector.get(TestabilityRegistry); var registry = (<Injector>refs[0].injector).get(TestabilityRegistry);
PromiseWrapper.all([ PromiseWrapper.all([
refs[0] refs[0]
.injector.asyncGet(Testability), .injector.asyncGet(Testability),

View File

@ -29,7 +29,11 @@ import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
export function main() { export function main() {
describe('DynamicComponentLoader', function() { describe('DynamicComponentLoader', function() {
describe("loading into existing location", () => { describe("loading into existing location", () => {
it('should work', inject([TestBed, AsyncTestCompleter], (tb, async) => { function ijTestBed(fn: (ts: TestBed, async: AsyncTestCompleter) => void) {
return inject([TestBed, AsyncTestCompleter], fn);
}
it('should work', ijTestBed((tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<dynamic-comp #dynamic></dynamic-comp>', template: '<dynamic-comp #dynamic></dynamic-comp>',
directives: [DynamicComp] directives: [DynamicComp]
@ -48,7 +52,7 @@ export function main() {
})); }));
it('should inject dependencies of the dynamically-loaded component', it('should inject dependencies of the dynamically-loaded component',
inject([TestBed, AsyncTestCompleter], (tb, async) => { ijTestBed((tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<dynamic-comp #dynamic></dynamic-comp>', template: '<dynamic-comp #dynamic></dynamic-comp>',
directives: [DynamicComp] directives: [DynamicComp]
@ -65,7 +69,7 @@ export function main() {
})); }));
it('should allow to destroy and create them via viewcontainer directives', it('should allow to destroy and create them via viewcontainer directives',
inject([TestBed, AsyncTestCompleter], (tb, async) => { ijTestBed((tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: template:
'<div><dynamic-comp #dynamic template="ng-if: ctxBoolProp"></dynamic-comp></div>', '<div><dynamic-comp #dynamic template="ng-if: ctxBoolProp"></dynamic-comp></div>',
@ -103,7 +107,8 @@ export function main() {
describe("loading next to an existing location", () => { describe("loading next to an existing location", () => {
it('should work', it('should work',
inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb, async) => { inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb: TestBed,
async) => {
tb.overrideView( tb.overrideView(
MyComp, MyComp,
new viewAnn.View( new viewAnn.View(
@ -121,7 +126,8 @@ export function main() {
})); }));
it('should return a disposable component ref', it('should return a disposable component ref',
inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb, async) => { inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb: TestBed,
async) => {
tb.overrideView( tb.overrideView(
MyComp, MyComp,
new viewAnn.View( new viewAnn.View(
@ -148,7 +154,8 @@ export function main() {
})); }));
it('should update host properties', it('should update host properties',
inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb, async) => { inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb: TestBed,
async) => {
tb.overrideView( tb.overrideView(
MyComp, MyComp,
new viewAnn.View( new viewAnn.View(
@ -175,7 +182,7 @@ export function main() {
describe('loading into a new location', () => { describe('loading into a new location', () => {
it('should allow to create, update and destroy components', it('should allow to create, update and destroy components',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<imp-ng-cmp #impview></imp-ng-cmp>', template: '<imp-ng-cmp #impview></imp-ng-cmp>',
directives: [ImperativeViewComponentUsingNgComponent] directives: [ImperativeViewComponentUsingNgComponent]
@ -206,10 +213,9 @@ export function main() {
}); });
describe('loadAsRoot', () => { describe('loadAsRoot', () => {
it('should allow to create, update and destroy components', it('should allow to create, update and destroy components',
inject([TestBed, AsyncTestCompleter, DynamicComponentLoader, DOCUMENT_TOKEN, Injector], inject([TestBed, AsyncTestCompleter, DynamicComponentLoader, DOCUMENT_TOKEN, Injector],
(tb, async, dcl, doc, injector) => { (tb: TestBed, async, dcl, doc, injector) => {
var rootEl = el('<child-cmp></child-cmp>'); var rootEl = el('<child-cmp></child-cmp>');
DOM.appendChild(doc.body, rootEl); DOM.appendChild(doc.body, rootEl);
dcl.loadAsRoot(ChildComp, null, injector) dcl.loadAsRoot(ChildComp, null, injector)

View File

@ -236,7 +236,7 @@ export function main() {
return ProtoElementInjector.create(parent, index, directiveBinding, hasShadowRoot, distance); return ProtoElementInjector.create(parent, index, directiveBinding, hasShadowRoot, distance);
} }
function humanize(tree, names: List<List<any>>) { function humanize(tree: TreeNode<any>, names: List<List<any>>) {
var lookupName = (item) => var lookupName = (item) =>
ListWrapper.last(ListWrapper.find(names, (pair) => pair[0] === item)); ListWrapper.last(ListWrapper.find(names, (pair) => pair[0] === item));

View File

@ -83,7 +83,8 @@ export function main() {
describe('react to record changes', function() { describe('react to record changes', function() {
it('should consume text node changes', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should consume text node changes',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({template: '<div>{{ctxProp}}</div>'})); tb.overrideView(MyComp, new viewAnn.View({template: '<div>{{ctxProp}}</div>'}));
tb.createView(MyComp, {context: ctx}) tb.createView(MyComp, {context: ctx})
.then((view) => { .then((view) => {
@ -96,7 +97,7 @@ export function main() {
})); }));
it('should consume element binding changes', it('should consume element binding changes',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({template: '<div [id]="ctxProp"></div>'})); tb.overrideView(MyComp, new viewAnn.View({template: '<div [id]="ctxProp"></div>'}));
tb.createView(MyComp, {context: ctx}) tb.createView(MyComp, {context: ctx})
@ -111,7 +112,7 @@ export function main() {
})); }));
it('should consume binding to aria-* attributes', it('should consume binding to aria-* attributes',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, tb.overrideView(MyComp,
new viewAnn.View({template: '<div [attr.aria-label]="ctxProp"></div>'})); new viewAnn.View({template: '<div [attr.aria-label]="ctxProp"></div>'}));
@ -133,7 +134,7 @@ export function main() {
})); }));
it('should consume binding to property names where attr name and property name do not match', it('should consume binding to property names where attr name and property name do not match',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, tb.overrideView(MyComp,
new viewAnn.View({template: '<div [tabindex]="ctxNumProp"></div>'})); new viewAnn.View({template: '<div [tabindex]="ctxNumProp"></div>'}));
@ -152,7 +153,7 @@ export function main() {
})); }));
it('should consume binding to camel-cased properties using dash-cased syntax in templates', it('should consume binding to camel-cased properties using dash-cased syntax in templates',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, tb.overrideView(MyComp,
new viewAnn.View({template: '<input [read-only]="ctxBoolProp">'})); new viewAnn.View({template: '<input [read-only]="ctxBoolProp">'}));
@ -171,7 +172,7 @@ export function main() {
})); }));
it('should consume binding to inner-html', it('should consume binding to inner-html',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, tb.overrideView(MyComp,
new viewAnn.View({template: '<div inner-html="{{ctxProp}}"></div>'})); new viewAnn.View({template: '<div inner-html="{{ctxProp}}"></div>'}));
@ -191,7 +192,7 @@ export function main() {
})); }));
it('should ignore bindings to unknown properties', it('should ignore bindings to unknown properties',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, tb.overrideView(MyComp,
new viewAnn.View({template: '<div unknown="{{ctxProp}}"></div>'})); new viewAnn.View({template: '<div unknown="{{ctxProp}}"></div>'}));
@ -207,7 +208,7 @@ export function main() {
})); }));
it('should consume directive watch expression change.', it('should consume directive watch expression change.',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var tpl = '<div>' + var tpl = '<div>' +
'<div my-dir [elprop]="ctxProp"></div>' + '<div my-dir [elprop]="ctxProp"></div>' +
'<div my-dir elprop="Hi there!"></div>' + '<div my-dir elprop="Hi there!"></div>' +
@ -243,7 +244,7 @@ export function main() {
}); });
it("should support pipes in bindings and bind config", it("should support pipes in bindings and bind config",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: template:
'<component-with-pipes #comp [prop]="ctxProp | double"></component-with-pipes>', '<component-with-pipes #comp [prop]="ctxProp | double"></component-with-pipes>',
@ -264,7 +265,8 @@ export function main() {
})); }));
}); });
it('should support nested components.', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should support nested components.',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView( tb.overrideView(
MyComp, MyComp,
new viewAnn.View({template: '<child-cmp></child-cmp>', directives: [ChildComp]})); new viewAnn.View({template: '<child-cmp></child-cmp>', directives: [ChildComp]}));
@ -281,7 +283,7 @@ export function main() {
// GH issue 328 - https://github.com/angular/angular/issues/328 // GH issue 328 - https://github.com/angular/angular/issues/328
it('should support different directive types on a single node', it('should support different directive types on a single node',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<child-cmp my-dir [elprop]="ctxProp"></child-cmp>', template: '<child-cmp my-dir [elprop]="ctxProp"></child-cmp>',
directives: [MyDir, ChildComp] directives: [MyDir, ChildComp]
@ -302,7 +304,7 @@ export function main() {
})); }));
it('should support directives where a binding attribute is not given', it('should support directives where a binding attribute is not given',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
// No attribute "el-prop" specified. // No attribute "el-prop" specified.
template: '<p my-dir></p>', template: '<p my-dir></p>',
@ -313,7 +315,7 @@ export function main() {
})); }));
it('should support directives where a selector matches property binding', it('should support directives where a selector matches property binding',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView( tb.overrideView(
MyComp, new viewAnn.View({template: '<p [id]="ctxProp"></p>', directives: [IdDir]})); MyComp, new viewAnn.View({template: '<p [id]="ctxProp"></p>', directives: [IdDir]}));
@ -334,7 +336,7 @@ export function main() {
})); }));
it('should allow specifying directives as bindings', it('should allow specifying directives as bindings',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<child-cmp></child-cmp>', template: '<child-cmp></child-cmp>',
directives: [bind(ChildComp).toClass(ChildComp)] directives: [bind(ChildComp).toClass(ChildComp)]
@ -350,7 +352,7 @@ export function main() {
})); }));
it('should read directives metadata from their binding token', it('should read directives metadata from their binding token',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<div public-api><div needs-public-api></div></div>', template: '<div public-api><div needs-public-api></div></div>',
directives: [bind(PublicApi).toClass(PrivateImpl), NeedsPublicApi] directives: [bind(PublicApi).toClass(PrivateImpl), NeedsPublicApi]
@ -360,7 +362,7 @@ export function main() {
})); }));
it('should support template directives via `<template>` elements.', it('should support template directives via `<template>` elements.',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: template:
'<div><template some-viewport var-greeting="some-tmpl"><copy-me>{{greeting}}</copy-me></template></div>', '<div><template some-viewport var-greeting="some-tmpl"><copy-me>{{greeting}}</copy-me></template></div>',
@ -382,7 +384,7 @@ export function main() {
})); }));
it('should support template directives via `template` attribute.', it('should support template directives via `template` attribute.',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: template:
'<div><copy-me template="some-viewport: var greeting=some-tmpl">{{greeting}}</copy-me></div>', '<div><copy-me template="some-viewport: var greeting=some-tmpl">{{greeting}}</copy-me></div>',
@ -403,7 +405,7 @@ export function main() {
})); }));
it('should allow to transplant embedded ProtoViews into other ViewContainers', it('should allow to transplant embedded ProtoViews into other ViewContainers',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: template:
'<some-directive><toolbar><template toolbarpart var-toolbar-prop="toolbarProp">{{ctxProp}},{{toolbarProp}},<cmp-with-parent></cmp-with-parent></template></toolbar></some-directive>', '<some-directive><toolbar><template toolbarpart var-toolbar-prop="toolbarProp">{{ctxProp}},{{toolbarProp}},<cmp-with-parent></cmp-with-parent></template></toolbar></some-directive>',
@ -424,7 +426,7 @@ export function main() {
describe("variable bindings", () => { describe("variable bindings", () => {
it('should assign a component to a var-', it('should assign a component to a var-',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<p><child-cmp var-alice></child-cmp></p>', template: '<p><child-cmp var-alice></child-cmp></p>',
directives: [ChildComp] directives: [ChildComp]
@ -440,7 +442,7 @@ export function main() {
})); }));
it('should assign a directive to a var-', it('should assign a directive to a var-',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<p><div [export-dir] #localdir="dir"></div></p>', template: '<p><div [export-dir] #localdir="dir"></div></p>',
directives: [ExportDir] directives: [ExportDir]
@ -456,7 +458,7 @@ export function main() {
})); }));
it('should make the assigned component accessible in property bindings', it('should make the assigned component accessible in property bindings',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<p><child-cmp var-alice></child-cmp>{{alice.ctxProp}}</p>', template: '<p><child-cmp var-alice></child-cmp>{{alice.ctxProp}}</p>',
directives: [ChildComp] directives: [ChildComp]
@ -474,7 +476,7 @@ export function main() {
})); }));
it('should assign two component instances each with a var-', it('should assign two component instances each with a var-',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<p><child-cmp var-alice></child-cmp><child-cmp var-bob></p>', template: '<p><child-cmp var-alice></child-cmp><child-cmp var-bob></p>',
directives: [ChildComp] directives: [ChildComp]
@ -494,7 +496,7 @@ export function main() {
})); }));
it('should assign the component instance to a var- with shorthand syntax', it('should assign the component instance to a var- with shorthand syntax',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView( tb.overrideView(
MyComp, MyComp,
new viewAnn.View( new viewAnn.View(
@ -511,7 +513,7 @@ export function main() {
})); }));
it('should assign the element instance to a user-defined variable', it('should assign the element instance to a user-defined variable',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView( tb.overrideView(
MyComp, new viewAnn.View({template: '<p><div var-alice><i>Hello</i></div></p>'})); MyComp, new viewAnn.View({template: '<p><div var-alice><i>Hello</i></div></p>'}));
@ -528,7 +530,7 @@ export function main() {
})); }));
it('should change dash-case to camel-case', it('should change dash-case to camel-case',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<p><child-cmp var-super-alice></child-cmp></p>', template: '<p><child-cmp var-super-alice></child-cmp></p>',
directives: [ChildComp] directives: [ChildComp]
@ -546,7 +548,7 @@ export function main() {
describe("ON_PUSH components", () => { describe("ON_PUSH components", () => {
it("should use ChangeDetectorRef to manually request a check", it("should use ChangeDetectorRef to manually request a check",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<push-cmp-with-ref #cmp></push-cmp-with-ref>', template: '<push-cmp-with-ref #cmp></push-cmp-with-ref>',
@ -573,7 +575,7 @@ export function main() {
})); }));
it("should be checked when its bindings got updated", it("should be checked when its bindings got updated",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>', template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
@ -597,7 +599,7 @@ export function main() {
})); }));
it('should not affect updating properties on the component', it('should not affect updating properties on the component',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<push-cmp-with-ref [prop]="ctxProp" #cmp></push-cmp-with-ref>', template: '<push-cmp-with-ref [prop]="ctxProp" #cmp></push-cmp-with-ref>',
directives: [[[PushCmpWithRef]]] directives: [[[PushCmpWithRef]]]
@ -622,7 +624,7 @@ export function main() {
}); });
it('should create a component that injects a @Parent', it('should create a component that injects a @Parent',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: template:
'<some-directive><cmp-with-parent #child></cmp-with-parent></some-directive>', '<some-directive><cmp-with-parent #child></cmp-with-parent></some-directive>',
@ -640,7 +642,7 @@ export function main() {
})); }));
it('should create a component that injects an @Ancestor', it('should create a component that injects an @Ancestor',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: ` template: `
<some-directive> <some-directive>
@ -662,7 +664,7 @@ export function main() {
})); }));
it('should create a component that injects an @Ancestor through viewcontainer directive', it('should create a component that injects an @Ancestor through viewcontainer directive',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: ` template: `
<some-directive> <some-directive>
@ -686,7 +688,7 @@ export function main() {
})); }));
it('should support events via EventEmitter', it('should support events via EventEmitter',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<div emitter listener></div>', template: '<div emitter listener></div>',
directives: [DirectiveEmitingEvent, DirectiveListeningEvent] directives: [DirectiveEmitingEvent, DirectiveListeningEvent]
@ -711,7 +713,8 @@ export function main() {
}); });
})); }));
it('should support [()] syntax', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should support [()] syntax',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<div [(control)]="ctxProp" two-way></div>', template: '<div [(control)]="ctxProp" two-way></div>',
directives: [DirectiveWithTwoWayBinding] directives: [DirectiveWithTwoWayBinding]
@ -738,7 +741,7 @@ export function main() {
if (DOM.supportsDOMEvents()) { if (DOM.supportsDOMEvents()) {
it("should support invoking methods on the host element via hostActions", it("should support invoking methods on the host element via hostActions",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<div update-host-actions></div>', template: '<div update-host-actions></div>',
directives: [DirectiveUpdatingHostActions] directives: [DirectiveUpdatingHostActions]
@ -760,7 +763,8 @@ export function main() {
})); }));
} }
it('should support render events', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should support render events',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView( tb.overrideView(
MyComp, MyComp,
new viewAnn.View( new viewAnn.View(
@ -782,7 +786,7 @@ export function main() {
})); }));
it('should support render global events', it('should support render global events',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView( tb.overrideView(
MyComp, MyComp,
new viewAnn.View( new viewAnn.View(
@ -810,7 +814,7 @@ export function main() {
})); }));
it('should support updating host element via hostAttributes', it('should support updating host element via hostAttributes',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<div update-host-attributes></div>', template: '<div update-host-attributes></div>',
directives: [DirectiveUpdatingHostAttributes] directives: [DirectiveUpdatingHostAttributes]
@ -827,7 +831,7 @@ export function main() {
})); }));
it('should support updating host element via hostProperties', it('should support updating host element via hostProperties',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<div update-host-properties></div>', template: '<div update-host-properties></div>',
directives: [DirectiveUpdatingHostProperties] directives: [DirectiveUpdatingHostProperties]
@ -851,7 +855,7 @@ export function main() {
if (DOM.supportsDOMEvents()) { if (DOM.supportsDOMEvents()) {
it('should support preventing default on render events', it('should support preventing default on render events',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: template:
'<input type="checkbox" listenerprevent></input><input type="checkbox" listenernoprevent></input>', '<input type="checkbox" listenerprevent></input><input type="checkbox" listenernoprevent></input>',
@ -873,7 +877,7 @@ export function main() {
} }
it('should support render global events from multiple directives', it('should support render global events from multiple directives',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<div *ng-if="ctxBoolProp" listener listenerother></div>', template: '<div *ng-if="ctxBoolProp" listener listenerother></div>',
directives: [NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther] directives: [NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
@ -911,7 +915,7 @@ export function main() {
describe('dynamic ViewContainers', () => { describe('dynamic ViewContainers', () => {
it('should allow to create a ViewContainerRef at any bound location', it('should allow to create a ViewContainerRef at any bound location',
inject([TestBed, AsyncTestCompleter, Compiler], (tb, async, compiler) => { inject([TestBed, AsyncTestCompleter, Compiler], (tb: TestBed, async, compiler) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<div><dynamic-vp #dynamic></dynamic-vp></div>', template: '<div><dynamic-vp #dynamic></dynamic-vp></div>',
directives: [DynamicViewport] directives: [DynamicViewport]
@ -929,7 +933,8 @@ export function main() {
}); });
it('should support static attributes', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should support static attributes',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView( tb.overrideView(
MyComp, MyComp,
new viewAnn.View( new viewAnn.View(
@ -948,7 +953,8 @@ export function main() {
}); });
describe("dependency injection", () => { describe("dependency injection", () => {
it("should support hostInjector", inject([TestBed, AsyncTestCompleter], (tb, async) => { it("should support hostInjector",
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: ` template: `
<directive-providing-injectable> <directive-providing-injectable>
@ -969,7 +975,7 @@ export function main() {
it('should prioritze hostInjector over viewInjector for the same binding', it('should prioritze hostInjector over viewInjector for the same binding',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: ` template: `
<directive-providing-injectable> <directive-providing-injectable>
@ -989,7 +995,8 @@ export function main() {
}); });
})); }));
it("should support viewInjector", inject([TestBed, AsyncTestCompleter], (tb, async) => { it("should support viewInjector",
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(DirectiveProvidingInjectableInView, new viewAnn.View({ tb.overrideView(DirectiveProvidingInjectableInView, new viewAnn.View({
template: ` template: `
<directive-consuming-injectable #consuming> <directive-consuming-injectable #consuming>
@ -1007,7 +1014,8 @@ export function main() {
}); });
})); }));
it("should support unbounded lookup", inject([TestBed, AsyncTestCompleter], (tb, async) => { it("should support unbounded lookup",
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: ` template: `
<directive-providing-injectable> <directive-providing-injectable>
@ -1038,7 +1046,7 @@ export function main() {
})); }));
it("should support the event-bus scenario", it("should support the event-bus scenario",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: ` template: `
<grand-parent-providing-event-bus> <grand-parent-providing-event-bus>
@ -1074,7 +1082,7 @@ export function main() {
describe("error handling", () => { describe("error handling", () => {
it('should report a meaningful error when a directive is missing annotation', it('should report a meaningful error when a directive is missing annotation',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, tb.overrideView(MyComp,
new viewAnn.View({directives: [SomeDirectiveMissingAnnotation]})); new viewAnn.View({directives: [SomeDirectiveMissingAnnotation]}));
@ -1082,11 +1090,12 @@ export function main() {
expect(e.message).toEqual( expect(e.message).toEqual(
`No Directive annotation found on ${stringify(SomeDirectiveMissingAnnotation)}`); `No Directive annotation found on ${stringify(SomeDirectiveMissingAnnotation)}`);
async.done(); async.done();
return null;
}); });
})); }));
it('should report a meaningful error when a directive is null', it('should report a meaningful error when a directive is null',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({directives: [[null]]})); tb.overrideView(MyComp, new viewAnn.View({directives: [[null]]}));
@ -1094,12 +1103,13 @@ export function main() {
expect(e.message).toEqual( expect(e.message).toEqual(
`Unexpected directive value 'null' on the View of component '${stringify(MyComp)}'`); `Unexpected directive value 'null' on the View of component '${stringify(MyComp)}'`);
async.done(); async.done();
return null;
}); });
})); }));
if (!IS_DARTIUM) { if (!IS_DARTIUM) {
it('should report a meaningful error when a directive is undefined', it('should report a meaningful error when a directive is undefined',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var undefinedValue; var undefinedValue;
@ -1109,12 +1119,13 @@ export function main() {
expect(e.message).toEqual( expect(e.message).toEqual(
`Unexpected directive value 'undefined' on the View of component '${stringify(MyComp)}'`); `Unexpected directive value 'undefined' on the View of component '${stringify(MyComp)}'`);
async.done(); async.done();
return null;
}); });
})); }));
} }
it('should specify a location of an error that happened during change detection (text)', it('should specify a location of an error that happened during change detection (text)',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({template: '{{a.b}}'})); tb.overrideView(MyComp, new viewAnn.View({template: '{{a.b}}'}));
@ -1127,7 +1138,7 @@ export function main() {
})); }));
it('should specify a location of an error that happened during change detection (element property)', it('should specify a location of an error that happened during change detection (element property)',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({template: '<div [prop]="a.b"></div>'})); tb.overrideView(MyComp, new viewAnn.View({template: '<div [prop]="a.b"></div>'}));
@ -1140,7 +1151,7 @@ export function main() {
})); }));
it('should specify a location of an error that happened during change detection (directive property)', it('should specify a location of an error that happened during change detection (directive property)',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView( tb.overrideView(
MyComp, MyComp,
@ -1156,7 +1167,8 @@ export function main() {
})); }));
}); });
it('should support imperative views', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should support imperative views',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView(MyComp, new viewAnn.View({ tb.overrideView(MyComp, new viewAnn.View({
template: '<simple-imp-cmp></simple-imp-cmp>', template: '<simple-imp-cmp></simple-imp-cmp>',
directives: [SimpleImperativeViewComponent] directives: [SimpleImperativeViewComponent]
@ -1210,27 +1222,27 @@ export function main() {
} }
it('should raise an error if no directive is registered for a template with template bindings', it('should raise an error if no directive is registered for a template with template bindings',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
expectCompileError(tb, '<div><div template="if: foo"></div></div>', expectCompileError(tb, '<div><div template="if: foo"></div></div>',
'Missing directive to handle \'if\' in <div template="if: foo">', 'Missing directive to handle \'if\' in <div template="if: foo">',
() => async.done()); () => async.done());
})); }));
it('should raise an error for missing template directive (1)', it('should raise an error for missing template directive (1)',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
expectCompileError(tb, '<div><template foo></template></div>', expectCompileError(tb, '<div><template foo></template></div>',
'Missing directive to handle: <template foo>', () => async.done()); 'Missing directive to handle: <template foo>', () => async.done());
})); }));
it('should raise an error for missing template directive (2)', it('should raise an error for missing template directive (2)',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
expectCompileError(tb, '<div><template *ng-if="condition"></template></div>', expectCompileError(tb, '<div><template *ng-if="condition"></template></div>',
'Missing directive to handle: <template *ng-if="condition">', 'Missing directive to handle: <template *ng-if="condition">',
() => async.done()); () => async.done());
})); }));
it('should raise an error for missing template directive (3)', it('should raise an error for missing template directive (3)',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
expectCompileError( expectCompileError(
tb, '<div *ng-if="condition"></div>', tb, '<div *ng-if="condition"></div>',
'Missing directive to handle \'if\' in MyComp: <div *ng-if="condition">', 'Missing directive to handle \'if\' in MyComp: <div *ng-if="condition">',

View File

@ -26,7 +26,7 @@ export function main() {
describe('Query API', () => { describe('Query API', () => {
it('should contain all direct child directives in the light dom', it('should contain all direct child directives in the light dom',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div text="1"></div>' + var template = '<div text="1"></div>' +
'<needs-query text="2"><div text="3">' + '<needs-query text="2"><div text="3">' +
'<div text="too-deep"></div>' + '<div text="too-deep"></div>' +
@ -43,7 +43,7 @@ export function main() {
})); }));
it('should contain all directives in the light dom when descendants flag is used', it('should contain all directives in the light dom when descendants flag is used',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div text="1"></div>' + var template = '<div text="1"></div>' +
'<needs-query-desc text="2"><div text="3">' + '<needs-query-desc text="2"><div text="3">' +
'<div text="4"></div>' + '<div text="4"></div>' +
@ -60,7 +60,7 @@ export function main() {
})); }));
it('should contain all directives in the light dom', it('should contain all directives in the light dom',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div text="1"></div>' + var template = '<div text="1"></div>' +
'<needs-query text="2"><div text="3"></div></needs-query>' + '<needs-query text="2"><div text="3"></div></needs-query>' +
'<div text="4"></div>'; '<div text="4"></div>';
@ -78,7 +78,7 @@ export function main() {
// but due to a bug with how injectors are hooked up query considers the // but due to a bug with how injectors are hooked up query considers the
// directives to be distances 2 instead of direct children. // directives to be distances 2 instead of direct children.
it('should reflect dynamically inserted directives', it('should reflect dynamically inserted directives',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = var template =
'<div text="1"></div>' + '<div text="1"></div>' +
'<needs-query-desc text="2"><div *ng-if="shouldShow" [text]="\'3\'"></div></needs-query-desc>' + '<needs-query-desc text="2"><div *ng-if="shouldShow" [text]="\'3\'"></div></needs-query-desc>' +
@ -98,7 +98,8 @@ export function main() {
}); });
})); }));
it('should reflect moved directives', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should reflect moved directives',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = var template =
'<div text="1"></div>' + '<div text="1"></div>' +
'<needs-query-desc text="2"><div *ng-for="var i of list" [text]="i"></div></needs-query-desc>' + '<needs-query-desc text="2"><div *ng-for="var i of list" [text]="i"></div></needs-query-desc>' +

View File

@ -32,7 +32,7 @@ export function main() {
beforeEach(() => { ctx = new MyComp(); }); beforeEach(() => { ctx = new MyComp(); });
it('should invoke lifecycle methods onChange > onInit > onCheck > onAllChangesDone', it('should invoke lifecycle methods onChange > onInit > onCheck > onAllChangesDone',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.overrideView( tb.overrideView(
MyComp, MyComp,
new viewAnn.View( new viewAnn.View(

View File

@ -18,7 +18,7 @@ import {Type} from 'angular2/src/facade/lang';
export function main() { export function main() {
describe("forwardRef integration", function() { describe("forwardRef integration", function() {
it('should instantiate components which are declared using forwardRef', it('should instantiate components which are declared using forwardRef',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.createView(App).then((view) => { tb.createView(App).then((view) => {
view.detectChanges(); view.detectChanges();
expect(view.rootNodes).toHaveText('frame(lock)'); expect(view.rootNodes).toHaveText('frame(lock)');

View File

@ -3,7 +3,7 @@ import {Key, KeyRegistry} from 'angular2/di';
export function main() { export function main() {
describe("key", function() { describe("key", function() {
var registry; var registry: KeyRegistry;
beforeEach(function() { registry = new KeyRegistry(); }); beforeEach(function() { registry = new KeyRegistry(); });

View File

@ -25,7 +25,7 @@ export function main() {
describe('binding to CSS class list', () => { describe('binding to CSS class list', () => {
it('should add classes specified in an object literal', it('should add classes specified in an object literal',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div [class]="{foo: true, bar: false}"></div>'; var template = '<div [class]="{foo: true, bar: false}"></div>';
tb.createView(TestComponent, {html: template}) tb.createView(TestComponent, {html: template})
@ -38,7 +38,7 @@ export function main() {
})); }));
it('should add and remove classes based on changes in object literal values', it('should add and remove classes based on changes in object literal values',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div [class]="{foo: condition, bar: !condition}"></div>'; var template = '<div [class]="{foo: condition, bar: !condition}"></div>';
tb.createView(TestComponent, {html: template}) tb.createView(TestComponent, {html: template})
@ -55,7 +55,7 @@ export function main() {
})); }));
it('should add and remove classes based on changes to the expression object', it('should add and remove classes based on changes to the expression object',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div [class]="expr"></div>'; var template = '<div [class]="expr"></div>';
tb.createView(TestComponent, {html: template}) tb.createView(TestComponent, {html: template})
@ -80,7 +80,7 @@ export function main() {
})); }));
it('should retain existing classes when expression evaluates to null', it('should retain existing classes when expression evaluates to null',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div [class]="expr"></div>'; var template = '<div [class]="expr"></div>';
tb.createView(TestComponent, {html: template}) tb.createView(TestComponent, {html: template})
@ -101,7 +101,7 @@ export function main() {
})); }));
it('should co-operate with the class attribute', it('should co-operate with the class attribute',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div [class]="expr" class="init foo"></div>'; var template = '<div [class]="expr" class="init foo"></div>';
tb.createView(TestComponent, {html: template}) tb.createView(TestComponent, {html: template})
@ -119,7 +119,7 @@ export function main() {
})); }));
it('should co-operate with the class attribute and class.name binding', it('should co-operate with the class attribute and class.name binding',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div class="init foo" [class]="expr" [class.baz]="condition"></div>'; var template = '<div class="init foo" [class]="expr" [class.baz]="condition"></div>';
tb.createView(TestComponent, {html: template}) tb.createView(TestComponent, {html: template})

View File

@ -27,7 +27,8 @@ export function main() {
var TEMPLATE = var TEMPLATE =
'<div><copy-me template="ng-for #item of items">{{item.toString()}};</copy-me></div>'; '<div><copy-me template="ng-for #item of items">{{item.toString()}};</copy-me></div>';
it('should reflect initial elements', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should reflect initial elements',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.createView(TestComponent, {html: TEMPLATE}) tb.createView(TestComponent, {html: TEMPLATE})
.then((view) => { .then((view) => {
view.detectChanges(); view.detectChanges();
@ -36,7 +37,8 @@ export function main() {
}); });
})); }));
it('should reflect added elements', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should reflect added elements',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.createView(TestComponent, {html: TEMPLATE}) tb.createView(TestComponent, {html: TEMPLATE})
.then((view) => { .then((view) => {
view.detectChanges(); view.detectChanges();
@ -49,7 +51,8 @@ export function main() {
}); });
})); }));
it('should reflect removed elements', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should reflect removed elements',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.createView(TestComponent, {html: TEMPLATE}) tb.createView(TestComponent, {html: TEMPLATE})
.then((view) => { .then((view) => {
view.detectChanges(); view.detectChanges();
@ -62,7 +65,8 @@ export function main() {
}); });
})); }));
it('should reflect moved elements', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should reflect moved elements',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.createView(TestComponent, {html: TEMPLATE}) tb.createView(TestComponent, {html: TEMPLATE})
.then((view) => { .then((view) => {
view.detectChanges(); view.detectChanges();
@ -77,7 +81,7 @@ export function main() {
})); }));
it('should reflect a mix of all changes (additions/removals/moves)', it('should reflect a mix of all changes (additions/removals/moves)',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.createView(TestComponent, {html: TEMPLATE}) tb.createView(TestComponent, {html: TEMPLATE})
.then((view) => { .then((view) => {
view.context.items = [0, 1, 2, 3, 4, 5]; view.context.items = [0, 1, 2, 3, 4, 5];
@ -92,7 +96,7 @@ export function main() {
})); }));
it('should iterate over an array of objects', it('should iterate over an array of objects',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<ul><li template="ng-for #item of items">{{item["name"]}};</li></ul>'; var template = '<ul><li template="ng-for #item of items">{{item["name"]}};</li></ul>';
tb.createView(TestComponent, {html: template}) tb.createView(TestComponent, {html: template})
@ -119,7 +123,8 @@ export function main() {
}); });
})); }));
it('should gracefully handle nulls', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should gracefully handle nulls',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<ul><li template="ng-for #item of null">{{item}};</li></ul>'; var template = '<ul><li template="ng-for #item of null">{{item}};</li></ul>';
tb.createView(TestComponent, {html: template}) tb.createView(TestComponent, {html: template})
.then((view) => { .then((view) => {
@ -130,7 +135,7 @@ export function main() {
})); }));
it('should gracefully handle ref changing to null and back', it('should gracefully handle ref changing to null and back',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.createView(TestComponent, {html: TEMPLATE}) tb.createView(TestComponent, {html: TEMPLATE})
.then((view) => { .then((view) => {
view.detectChanges(); view.detectChanges();
@ -148,7 +153,7 @@ export function main() {
})); }));
it('should throw on ref changing to string', it('should throw on ref changing to string',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.createView(TestComponent, {html: TEMPLATE}) tb.createView(TestComponent, {html: TEMPLATE})
.then((view) => { .then((view) => {
view.detectChanges(); view.detectChanges();
@ -160,7 +165,8 @@ export function main() {
}); });
})); }));
it('should works with duplicates', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should works with duplicates',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
tb.createView(TestComponent, {html: TEMPLATE}) tb.createView(TestComponent, {html: TEMPLATE})
.then((view) => { .then((view) => {
var a = new Foo(); var a = new Foo();
@ -171,7 +177,8 @@ export function main() {
}); });
})); }));
it('should repeat over nested arrays', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should repeat over nested arrays',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div>' + var template = '<div>' +
'<div template="ng-for #item of items">' + '<div template="ng-for #item of items">' +
'<div template="ng-for #subitem of item">' + '<div template="ng-for #subitem of item">' +
@ -197,7 +204,7 @@ export function main() {
})); }));
it('should repeat over nested arrays with no intermediate element', it('should repeat over nested arrays with no intermediate element',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div><template [ng-for] #item [ng-for-of]="items">' + var template = '<div><template [ng-for] #item [ng-for-of]="items">' +
'<div template="ng-for #subitem of item">' + '<div template="ng-for #subitem of item">' +
'{{subitem}}-{{item.length}};' + '{{subitem}}-{{item.length}};' +
@ -216,7 +223,8 @@ export function main() {
}); });
})); }));
it('should display indices correctly', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should display indices correctly',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = var template =
'<div><copy-me template="ng-for: var item of items; var i=index">{{i.toString()}}</copy-me></div>'; '<div><copy-me template="ng-for: var item of items; var i=index">{{i.toString()}}</copy-me></div>';

View File

@ -22,7 +22,8 @@ import {NgIf} from 'angular2/src/directives/ng_if';
export function main() { export function main() {
describe('if directive', () => { describe('if directive', () => {
it('should work in a template attribute', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should work in a template attribute',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var html = '<div><copy-me template="ng-if booleanCondition">hello</copy-me></div>'; var html = '<div><copy-me template="ng-if booleanCondition">hello</copy-me></div>';
tb.createView(TestComponent, {html: html}) tb.createView(TestComponent, {html: html})
@ -34,7 +35,8 @@ export function main() {
}); });
})); }));
it('should work in a template element', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should work in a template element',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var html = var html =
'<div><template [ng-if]="booleanCondition"><copy-me>hello2</copy-me></template></div>'; '<div><template [ng-if]="booleanCondition"><copy-me>hello2</copy-me></template></div>';
@ -48,7 +50,7 @@ export function main() {
})); }));
it('should toggle node when condition changes', it('should toggle node when condition changes',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var html = '<div><copy-me template="ng-if booleanCondition">hello</copy-me></div>'; var html = '<div><copy-me template="ng-if booleanCondition">hello</copy-me></div>';
tb.createView(TestComponent, {html: html}) tb.createView(TestComponent, {html: html})
@ -72,7 +74,8 @@ export function main() {
}); });
})); }));
it('should handle nested if correctly', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should handle nested if correctly',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var html = var html =
'<div><template [ng-if]="booleanCondition"><copy-me *ng-if="nestedBooleanCondition">hello</copy-me></template></div>'; '<div><template [ng-if]="booleanCondition"><copy-me *ng-if="nestedBooleanCondition">hello</copy-me></template></div>';
@ -107,7 +110,8 @@ export function main() {
}); });
})); }));
it('should update several nodes with if', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should update several nodes with if',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var html = var html =
'<div>' + '<div>' +
'<copy-me template="ng-if numberCondition + 1 >= 2">helloNumber</copy-me>' + '<copy-me template="ng-if numberCondition + 1 >= 2">helloNumber</copy-me>' +
@ -139,7 +143,7 @@ export function main() {
if (!IS_DARTIUM) { if (!IS_DARTIUM) {
it('should not add the element twice if the condition goes from true to true (JS)', it('should not add the element twice if the condition goes from true to true (JS)',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>'; var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
tb.createView(TestComponent, {html: html}) tb.createView(TestComponent, {html: html})
@ -158,7 +162,7 @@ export function main() {
})); }));
it('should not recreate the element if the condition goes from true to true (JS)', it('should not recreate the element if the condition goes from true to true (JS)',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>'; var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
tb.createView(TestComponent, {html: html}) tb.createView(TestComponent, {html: html})
@ -177,7 +181,7 @@ export function main() {
if (IS_DARTIUM) { if (IS_DARTIUM) {
it('should not create the element if the condition is not a boolean (DART)', it('should not create the element if the condition is not a boolean (DART)',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>'; var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
tb.createView(TestComponent, {html: html}) tb.createView(TestComponent, {html: html})

View File

@ -21,7 +21,8 @@ import {TestBed} from 'angular2/src/test_lib/test_bed';
export function main() { export function main() {
describe('switch', () => { describe('switch', () => {
describe('switch value changes', () => { describe('switch value changes', () => {
it('should switch amongst when values', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should switch amongst when values',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div>' + var template = '<div>' +
'<ul [ng-switch]="switchValue">' + '<ul [ng-switch]="switchValue">' +
'<template [ng-switch-when]="\'a\'"><li>when a</li></template>' + '<template [ng-switch-when]="\'a\'"><li>when a</li></template>' +
@ -46,7 +47,7 @@ export function main() {
})); }));
it('should switch amongst when values with fallback to default', it('should switch amongst when values with fallback to default',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div>' + var template = '<div>' +
'<ul [ng-switch]="switchValue">' + '<ul [ng-switch]="switchValue">' +
'<li template="ng-switch-when \'a\'">when a</li>' + '<li template="ng-switch-when \'a\'">when a</li>' +
@ -71,7 +72,7 @@ export function main() {
})); }));
it('should support multiple whens with the same value', it('should support multiple whens with the same value',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div>' + var template = '<div>' +
'<ul [ng-switch]="switchValue">' + '<ul [ng-switch]="switchValue">' +
'<template [ng-switch-when]="\'a\'"><li>when a1;</li></template>' + '<template [ng-switch-when]="\'a\'"><li>when a1;</li></template>' +
@ -101,7 +102,8 @@ export function main() {
}); });
describe('when values changes', () => { describe('when values changes', () => {
it('should switch amongst when values', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should switch amongst when values',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div>' + var template = '<div>' +
'<ul [ng-switch]="switchValue">' + '<ul [ng-switch]="switchValue">' +
'<template [ng-switch-when]="when1"><li>when 1;</li></template>' + '<template [ng-switch-when]="when1"><li>when 1;</li></template>' +

View File

@ -22,7 +22,8 @@ import {TestBed} from 'angular2/src/test_lib/test_bed';
export function main() { export function main() {
describe('non-bindable', () => { describe('non-bindable', () => {
it('should not interpolate children', inject([TestBed, AsyncTestCompleter], (tb, async) => { it('should not interpolate children',
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div>{{text}}<span ng-non-bindable>{{text}}</span></div>'; var template = '<div>{{text}}<span ng-non-bindable>{{text}}</span></div>';
tb.createView(TestComponent, {html: template}) tb.createView(TestComponent, {html: template})
.then((view) => { .then((view) => {
@ -33,7 +34,7 @@ export function main() {
})); }));
it('should ignore directives on child nodes', it('should ignore directives on child nodes',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div ng-non-bindable><span id=child test-dec>{{text}}</span></div>'; var template = '<div ng-non-bindable><span id=child test-dec>{{text}}</span></div>';
tb.createView(TestComponent, {html: template}) tb.createView(TestComponent, {html: template})
.then((view) => { .then((view) => {
@ -45,7 +46,7 @@ export function main() {
})); }));
it('should trigger directives on the same node', it('should trigger directives on the same node',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var template = '<div><span id=child ng-non-bindable test-dec>{{text}}</span></div>'; var template = '<div><span id=child ng-non-bindable test-dec>{{text}}</span></div>';
tb.createView(TestComponent, {html: template}) tb.createView(TestComponent, {html: template})
.then((view) => { .then((view) => {

View File

@ -34,7 +34,7 @@ import {
export function main() { export function main() {
describe("integration tests", () => { describe("integration tests", () => {
it("should initialize DOM elements with the given form object", it("should initialize DOM elements with the given form object",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var ctx = MyComp.create({form: new ControlGroup({"login": new Control("loginValue")})}); var ctx = MyComp.create({form: new ControlGroup({"login": new Control("loginValue")})});
var t = `<div [ng-form-model]="form"> var t = `<div [ng-form-model]="form">
@ -52,7 +52,7 @@ export function main() {
})); }));
it("should update the control group values on DOM change", it("should update the control group values on DOM change",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var form = new ControlGroup({"login": new Control("oldValue")}); var form = new ControlGroup({"login": new Control("oldValue")});
var ctx = MyComp.create({form: form}); var ctx = MyComp.create({form: form});
@ -92,7 +92,8 @@ export function main() {
}); });
}))); })));
it("should work with single controls", inject([TestBed, AsyncTestCompleter], (tb, async) => { it("should work with single controls",
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var control = new Control("loginValue"); var control = new Control("loginValue");
var ctx = MyComp.create({form: control}); var ctx = MyComp.create({form: control});
@ -113,7 +114,7 @@ export function main() {
})); }));
it("should update DOM elements when rebinding the control group", it("should update DOM elements when rebinding the control group",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var form = new ControlGroup({"login": new Control("oldValue")}); var form = new ControlGroup({"login": new Control("oldValue")});
var ctx = MyComp.create({form: form}); var ctx = MyComp.create({form: form});
@ -134,7 +135,7 @@ export function main() {
})); }));
it("should update DOM elements when updating the value of a control", it("should update DOM elements when updating the value of a control",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var login = new Control("oldValue"); var login = new Control("oldValue");
var form = new ControlGroup({"login": login}); var form = new ControlGroup({"login": login});
var ctx = MyComp.create({form: form}); var ctx = MyComp.create({form: form});
@ -158,7 +159,7 @@ export function main() {
})); }));
it("should mark controls as touched after interacting with the DOM control", it("should mark controls as touched after interacting with the DOM control",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var login = new Control("oldValue"); var login = new Control("oldValue");
var form = new ControlGroup({"login": login}); var form = new ControlGroup({"login": login});
var ctx = MyComp.create({form: form}); var ctx = MyComp.create({form: form});
@ -184,7 +185,8 @@ export function main() {
})); }));
describe("different control types", () => { describe("different control types", () => {
it("should support <input type=text>", inject([TestBed, AsyncTestCompleter], (tb, async) => { it("should support <input type=text>",
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var ctx = MyComp.create({form: new ControlGroup({"text": new Control("old")})}); var ctx = MyComp.create({form: new ControlGroup({"text": new Control("old")})});
var t = `<div [ng-form-model]="form"> var t = `<div [ng-form-model]="form">
@ -206,7 +208,7 @@ export function main() {
})); }));
it("should support <input> without type", it("should support <input> without type",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var ctx = MyComp.create({form: new ControlGroup({"text": new Control("old")})}); var ctx = MyComp.create({form: new ControlGroup({"text": new Control("old")})});
var t = `<div [ng-form-model]="form"> var t = `<div [ng-form-model]="form">
@ -227,7 +229,8 @@ export function main() {
}); });
})); }));
it("should support <textarea>", inject([TestBed, AsyncTestCompleter], (tb, async) => { it("should support <textarea>",
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var ctx = MyComp.create({form: new ControlGroup({"text": new Control('old')})}); var ctx = MyComp.create({form: new ControlGroup({"text": new Control('old')})});
var t = `<div [ng-form-model]="form"> var t = `<div [ng-form-model]="form">
@ -248,7 +251,8 @@ export function main() {
}); });
})); }));
it("should support <type=checkbox>", inject([TestBed, AsyncTestCompleter], (tb, async) => { it("should support <type=checkbox>",
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var ctx = MyComp.create({form: new ControlGroup({"checkbox": new Control(true)})}); var ctx = MyComp.create({form: new ControlGroup({"checkbox": new Control(true)})});
var t = `<div [ng-form-model]="form"> var t = `<div [ng-form-model]="form">
@ -269,7 +273,7 @@ export function main() {
}); });
})); }));
it("should support <select>", inject([TestBed, AsyncTestCompleter], (tb, async) => { it("should support <select>", inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var ctx = MyComp.create({form: new ControlGroup({"city": new Control("SF")})}); var ctx = MyComp.create({form: new ControlGroup({"city": new Control("SF")})});
var t = `<div [ng-form-model]="form"> var t = `<div [ng-form-model]="form">
@ -297,7 +301,7 @@ export function main() {
})); }));
it("should support custom value accessors", it("should support custom value accessors",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var ctx = MyComp.create({form: new ControlGroup({"name": new Control("aa")})}); var ctx = MyComp.create({form: new ControlGroup({"name": new Control("aa")})});
var t = `<div [ng-form-model]="form"> var t = `<div [ng-form-model]="form">
@ -321,7 +325,7 @@ export function main() {
describe("validations", () => { describe("validations", () => {
it("should use validators defined in html", it("should use validators defined in html",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var form = new ControlGroup({"login": new Control("aa")}); var form = new ControlGroup({"login": new Control("aa")});
var ctx = MyComp.create({form: form}); var ctx = MyComp.create({form: form});
@ -345,7 +349,7 @@ export function main() {
})); }));
it("should use validators defined in the model", it("should use validators defined in the model",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var form = new ControlGroup({"login": new Control("aa", Validators.required)}); var form = new ControlGroup({"login": new Control("aa", Validators.required)});
var ctx = MyComp.create({form: form}); var ctx = MyComp.create({form: form});
@ -371,7 +375,7 @@ export function main() {
describe("nested forms", () => { describe("nested forms", () => {
it("should init DOM with the given form object", it("should init DOM with the given form object",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var form = var form =
new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})}); new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})});
var ctx = MyComp.create({form: form}); var ctx = MyComp.create({form: form});
@ -392,7 +396,7 @@ export function main() {
})); }));
it("should update the control group values on DOM change", it("should update the control group values on DOM change",
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
var form = var form =
new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})}); new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})});
var ctx = MyComp.create({form: form}); var ctx = MyComp.create({form: form});
@ -468,7 +472,7 @@ export function main() {
describe("template-driven forms", () => { describe("template-driven forms", () => {
it("should add new controls and control groups", it("should add new controls and control groups",
inject([TestBed], fakeAsync(tb => { inject([TestBed], fakeAsync((tb: TestBed) => {
var ctx = MyComp.create({name: null}); var ctx = MyComp.create({name: null});
var t = `<form> var t = `<form>
@ -491,7 +495,7 @@ export function main() {
}))); })));
it("should emit ng-submit event on submit", it("should emit ng-submit event on submit",
inject([TestBed], fakeAsync(tb => { inject([TestBed], fakeAsync((tb: TestBed) => {
var ctx = MyComp.create({name: 'old'}); var ctx = MyComp.create({name: 'old'});
var t = `<div><form (ng-submit)="name='updated'"></form></div>`; var t = `<div><form (ng-submit)="name='updated'"></form></div>`;
@ -508,7 +512,7 @@ export function main() {
}))); })));
it("should not create a template-driven form when ng-no-form is used", it("should not create a template-driven form when ng-no-form is used",
inject([TestBed], fakeAsync(tb => { inject([TestBed], fakeAsync((tb: TestBed) => {
var ctx = MyComp.create({name: null}); var ctx = MyComp.create({name: null});
var t = `<form ng-no-form> var t = `<form ng-no-form>
@ -522,7 +526,7 @@ export function main() {
}); });
}))); })));
it("should remove controls", inject([TestBed], fakeAsync(tb => { it("should remove controls", inject([TestBed], fakeAsync((tb: TestBed) => {
var ctx = MyComp.create({name: 'show'}); var ctx = MyComp.create({name: 'show'});
var t = `<form> var t = `<form>
@ -550,7 +554,7 @@ export function main() {
}))); })));
it("should remove control groups", it("should remove control groups",
inject([TestBed], fakeAsync(tb => { inject([TestBed], fakeAsync((tb: TestBed) => {
var ctx = MyComp.create({name: 'show'}); var ctx = MyComp.create({name: 'show'});
@ -579,7 +583,7 @@ export function main() {
}))); })));
it("should support ng-model for complex forms", it("should support ng-model for complex forms",
inject([TestBed], fakeAsync(tb => { inject([TestBed], fakeAsync((tb: TestBed) => {
var ctx = MyComp.create({name: "oldValue"}); var ctx = MyComp.create({name: "oldValue"});
var t = `<form> var t = `<form>
@ -606,7 +610,7 @@ export function main() {
it("should support ng-model for single fields", it("should support ng-model for single fields",
inject([TestBed], fakeAsync(tb => { inject([TestBed], fakeAsync((tb: TestBed) => {
var ctx = MyComp.create({name: "oldValue"}); var ctx = MyComp.create({name: "oldValue"});
var t = `<div><input type="text" [(ng-model)]="name"></div>`; var t = `<div><input type="text" [(ng-model)]="name"></div>`;
@ -632,7 +636,7 @@ export function main() {
describe("setting status classes", () => { describe("setting status classes", () => {
it("should work with single fields", it("should work with single fields",
inject([TestBed], fakeAsync(tb => { inject([TestBed], fakeAsync((tb: TestBed) => {
var form = new Control("", Validators.required); var form = new Control("", Validators.required);
var ctx = MyComp.create({form: form}); var ctx = MyComp.create({form: form});
@ -664,7 +668,7 @@ export function main() {
}))); })));
it("should work with complex model-driven forms", it("should work with complex model-driven forms",
inject([TestBed], fakeAsync(tb => { inject([TestBed], fakeAsync((tb: TestBed) => {
var form = new ControlGroup({"name": new Control("", Validators.required)}); var form = new ControlGroup({"name": new Control("", Validators.required)});
var ctx = MyComp.create({form: form}); var ctx = MyComp.create({form: form});
@ -697,7 +701,7 @@ export function main() {
}))); })));
it("should work with ng-model", it("should work with ng-model",
inject([TestBed], fakeAsync(tb => { inject([TestBed], fakeAsync((tb: TestBed) => {
var ctx = MyComp.create({name: ""}); var ctx = MyComp.create({name: ""});
var t = `<div><input [(ng-model)]="name" required></div>`; var t = `<div><input [(ng-model)]="name" required></div>`;

View File

@ -352,7 +352,7 @@ export function main() {
describe("ControlArray", () => { describe("ControlArray", () => {
describe("adding/removing", () => { describe("adding/removing", () => {
var a; var a: ControlArray;
var c1, c2, c3; var c1, c2, c3;
beforeEach(() => { beforeEach(() => {
@ -434,7 +434,8 @@ export function main() {
}); });
describe("dirty", () => { describe("dirty", () => {
var c, a; var c: Control;
var a: ControlArray;
beforeEach(() => { beforeEach(() => {
c = new Control('value'); c = new Control('value');
@ -451,7 +452,8 @@ export function main() {
}); });
describe("valueChanges", () => { describe("valueChanges", () => {
var a, c1, c2; var a: ControlArray;
var c1, c2;
beforeEach(() => { beforeEach(() => {
c1 = new Control("old1"); c1 = new Control("old1");

View File

@ -15,7 +15,7 @@ import {PromiseWrapper} from 'angular2/src/facade/async';
export function main() { export function main() {
describe('XHRImpl', () => { describe('XHRImpl', () => {
var xhr; var xhr: XHRImpl;
var url200 = '/base/modules/angular2/test/services/static_assets/200.html'; var url200 = '/base/modules/angular2/test/services/static_assets/200.html';
var url404 = '/base/modules/angular2/test/services/static_assets/404.html'; var url404 = '/base/modules/angular2/test/services/static_assets/404.html';
@ -33,6 +33,7 @@ export function main() {
PromiseWrapper.catchError(xhr.get(url404), (e) => { PromiseWrapper.catchError(xhr.get(url404), (e) => {
expect(e).toEqual(`Failed to load ${url404}`); expect(e).toEqual(`Failed to load ${url404}`);
async.done(); async.done();
return null;
}); });
})); }));
}); });

View File

@ -16,7 +16,7 @@ import {isPresent} from 'angular2/src/facade/lang';
export function main() { export function main() {
describe('MockXHR', () => { describe('MockXHR', () => {
var xhr; var xhr: MockXHR;
beforeEach(() => { xhr = new MockXHR(); }); beforeEach(() => { xhr = new MockXHR(); });

View File

@ -161,7 +161,7 @@ export class PerflogMetric extends Metric {
} }
} }
_aggregateEvents(events, markName): StringMap<string, any> { _aggregateEvents(events: List<StringMap<string, any>>, markName): StringMap<string, any> {
var result = {'scriptTime': 0, 'pureScriptTime': 0}; var result = {'scriptTime': 0, 'pureScriptTime': 0};
if (this._perfLogFeatures.gc) { if (this._perfLogFeatures.gc) {
result['gcTime'] = 0; result['gcTime'] = 0;

View File

@ -51,7 +51,7 @@ export class IOsDriverExtension extends WebDriverExtension {
}); });
} }
_convertPerfRecordsToEvents(records, events = null) { _convertPerfRecordsToEvents(records: any[], events = null) {
if (isBlank(events)) { if (isBlank(events)) {
events = []; events = [];
} }

View File

@ -27,7 +27,7 @@ import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
export function main() { export function main() {
describe('runner', () => { describe('runner', () => {
var injector; var injector: Injector;
var runner; var runner;
function createRunner(defaultBindings = null) { function createRunner(defaultBindings = null) {

View File

@ -120,7 +120,7 @@
"temp": "^0.8.1", "temp": "^0.8.1",
"ternary-stream": "^1.2.3", "ternary-stream": "^1.2.3",
"through2": "^0.6.1", "through2": "^0.6.1",
"ts2dart": "^0.5.9", "ts2dart": "^0.6.0",
"tsd": "^0.6.0", "tsd": "^0.6.0",
"typescript": "alexeagle/TypeScript#error_is_class", "typescript": "alexeagle/TypeScript#error_is_class",
"vinyl": "^0.4.6", "vinyl": "^0.4.6",

View File

@ -54,7 +54,11 @@ function getSourceTree() {
'angular2/test/http/**/*', 'angular2/test/http/**/*',
'angular2/http.ts' 'angular2/http.ts'
]); ]);
var transpiled = ts2dart(tsInputTree, {generateLibraryName: true, generateSourceMap: false}); var transpiled = ts2dart(tsInputTree, {
generateLibraryName: true,
generateSourceMap: false,
translateBuiltins: true,
});
// Native sources, dart only examples, etc. // Native sources, dart only examples, etc.
var dartSrcs = modulesFunnel(['**/*.dart', '**/*.ng_meta.json', '**/css/**']); var dartSrcs = modulesFunnel(['**/*.dart', '**/*.ng_meta.json', '**/css/**']);
return mergeTrees([transpiled, dartSrcs]); return mergeTrees([transpiled, dartSrcs]);

View File

@ -6,6 +6,7 @@ export interface TranspilerOptions {
generateLibraryName?: boolean; generateLibraryName?: boolean;
generateSourceMap?: boolean; generateSourceMap?: boolean;
basePath?: string; basePath?: string;
translateBuiltins?: boolean;
} }
export class Transpiler { export class Transpiler {