From f3d741854a94b63e41aa5c0f7fa2415ad70cd1ea Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Thu, 11 Jun 2015 18:50:41 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20add=20types=20for=20ts2dart's=20fa=C3=A7?= =?UTF-8?q?ade=20handling.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... in many, many places. --- .../dynamic_change_detector.ts | 5 +- .../src/change_detection/parser/ast.ts | 47 +++---- .../pipes/iterable_changes.ts | 2 +- .../src/core/compiler/element_injector.ts | 2 +- .../angular2/src/forms/directives/ng_model.ts | 3 +- .../src/render/dom/events/hammer_gestures.ts | 2 +- modules/angular2/src/router/router.ts | 4 +- modules/angular2/src/test_lib/test_bed.ts | 2 +- modules/angular2/src/test_lib/utils.ts | 2 +- .../change_detection/parser/locals_spec.ts | 2 +- .../pipes/iterable_changes_spec.ts | 59 ++++---- .../angular2/test/core/application_spec.ts | 4 +- .../compiler/dynamic_component_loader_spec.ts | 24 ++-- .../core/compiler/element_injector_spec.ts | 2 +- .../test/core/compiler/integration_spec.ts | 128 ++++++++++-------- .../core/compiler/query_integration_spec.ts | 11 +- .../directive_lifecycle_integration_spec.ts | 2 +- .../test/core/forward_ref_integration_spec.ts | 2 +- modules/angular2/test/di/key_spec.ts | 2 +- .../angular2/test/directives/class_spec.ts | 12 +- .../angular2/test/directives/ng_for_spec.ts | 34 +++-- .../angular2/test/directives/ng_if_spec.ts | 20 +-- .../test/directives/ng_switch_spec.ts | 10 +- .../test/directives/non_bindable_spec.ts | 7 +- .../angular2/test/forms/integration_spec.ts | 56 ++++---- modules/angular2/test/forms/model_spec.ts | 8 +- modules/angular2/test/render/xhr_impl_spec.ts | 3 +- modules/angular2/test/render/xhr_mock_spec.ts | 2 +- .../benchpress/src/metric/perflog_metric.ts | 2 +- .../src/webdriver/ios_driver_extension.ts | 2 +- modules/benchpress/test/runner_spec.ts | 2 +- package.json | 2 +- tools/broccoli/trees/dart_tree.ts | 6 +- tools/broccoli/ts2dart.d.ts | 1 + 34 files changed, 259 insertions(+), 213 deletions(-) diff --git a/modules/angular2/src/change_detection/dynamic_change_detector.ts b/modules/angular2/src/change_detection/dynamic_change_detector.ts index c41551e8b5..fde3e8dc53 100644 --- a/modules/angular2/src/change_detection/dynamic_change_detector.ts +++ b/modules/angular2/src/change_detection/dynamic_change_detector.ts @@ -1,5 +1,6 @@ import {isPresent, isBlank, BaseException, FunctionWrapper} from 'angular2/src/facade/lang'; 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 {BindingRecord} from './binding_record'; @@ -12,7 +13,7 @@ import {ProtoRecord, RecordType} from './proto_record'; import {ExpressionChangedAfterItHasBeenChecked, ChangeDetectionError} from './exceptions'; export class DynamicChangeDetector extends AbstractChangeDetector { - locals: any = null; + locals: Locals = null; values: List; changes: List; pipes: List; @@ -36,7 +37,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector { 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.values[0] = context; this.locals = locals; diff --git a/modules/angular2/src/change_detection/parser/ast.ts b/modules/angular2/src/change_detection/parser/ast.ts index 46bdb522eb..45585a90f1 100644 --- a/modules/angular2/src/change_detection/parser/ast.ts +++ b/modules/angular2/src/change_detection/parser/ast.ts @@ -1,12 +1,13 @@ import {isBlank, isPresent, FunctionWrapper, BaseException} from "angular2/src/facade/lang"; import {List, Map, ListWrapper, StringMapWrapper} from "angular2/src/facade/collection"; +import {Locals} from "./locals"; 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; } - 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; } @@ -14,7 +15,7 @@ export class AST { } export class EmptyExpr extends AST { - eval(context, locals) { return null; } + eval(context, locals: Locals) { return null; } visit(visitor: AstVisitor) { // do nothing @@ -22,7 +23,7 @@ export class EmptyExpr 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); } } @@ -33,7 +34,7 @@ export class ImplicitReceiver extends AST { export class Chain extends AST { constructor(public expressions: List) { super(); } - eval(context, locals) { + eval(context, locals: Locals) { var result; for (var i = 0; i < this.expressions.length; i++) { var last = this.expressions[i].eval(context, locals); @@ -48,7 +49,7 @@ export class Chain extends AST { export class Conditional extends AST { constructor(public condition: AST, public trueExp: AST, public falseExp: AST) { super(); } - eval(context, locals) { + eval(context, locals: Locals) { if (this.condition.eval(context, locals)) { return this.trueExp.eval(context, locals); } else { @@ -65,7 +66,7 @@ export class AccessMember extends AST { super(); } - eval(context, locals) { + eval(context, locals: Locals) { if (this.receiver instanceof ImplicitReceiver && isPresent(locals) && locals.contains(this.name)) { return locals.get(this.name); @@ -77,7 +78,7 @@ export class AccessMember extends AST { get isAssignable(): boolean { return true; } - assign(context, locals, value) { + assign(context, locals: Locals, value) { var evaluatedContext = this.receiver.eval(context, locals); if (this.receiver instanceof ImplicitReceiver && isPresent(locals) && @@ -97,7 +98,7 @@ export class SafeAccessMember extends AST { super(); } - eval(context, locals) { + eval(context, locals: Locals) { var evaluatedReceiver = this.receiver.eval(context, locals); return isBlank(evaluatedReceiver) ? null : this.getter(evaluatedReceiver); } @@ -108,7 +109,7 @@ export class SafeAccessMember extends AST { export class KeyedAccess extends AST { constructor(public obj: AST, public key: AST) { super(); } - eval(context, locals) { + eval(context, locals: Locals) { var obj: any = this.obj.eval(context, locals); var key: any = this.key.eval(context, locals); return obj[key]; @@ -116,7 +117,7 @@ export class KeyedAccess extends AST { get isAssignable(): boolean { return true; } - assign(context, locals, value) { + assign(context, locals: Locals, value) { var obj: any = this.obj.eval(context, locals); var key: any = this.key.eval(context, locals); obj[key] = value; @@ -138,7 +139,7 @@ export class Pipe extends AST { export class LiteralPrimitive extends AST { constructor(public value) { super(); } - eval(context, locals) { return this.value; } + eval(context, locals: Locals) { return this.value; } visit(visitor: AstVisitor) { return visitor.visitLiteralPrimitive(this); } } @@ -146,7 +147,7 @@ export class LiteralPrimitive extends AST { export class LiteralArray extends AST { constructor(public expressions: List) { super(); } - eval(context, locals) { + eval(context, locals: 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 { constructor(public keys: List, public values: List) { super(); } - eval(context, locals) { + eval(context, locals: Locals) { var res = StringMapWrapper.create(); for (var i = 0; i < this.keys.length; ++i) { 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 { 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); switch (this.operation) { case '&&': @@ -229,7 +230,7 @@ export class Binary extends AST { export class PrefixNot extends AST { 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); } } @@ -237,7 +238,7 @@ export class PrefixNot extends AST { export class Assignment extends AST { 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)); } @@ -250,7 +251,7 @@ export class MethodCall extends AST { super(); } - eval(context, locals) { + eval(context, locals: Locals) { var evaluatedArgs = evalList(context, locals, this.args); if (this.receiver instanceof ImplicitReceiver && isPresent(locals) && locals.contains(this.name)) { @@ -271,7 +272,7 @@ export class SafeMethodCall extends AST { super(); } - eval(context, locals) { + eval(context, locals: Locals) { var evaluatedReceiver = this.receiver.eval(context, locals); if (isBlank(evaluatedReceiver)) return null; var evaluatedArgs = evalList(context, locals, this.args); @@ -284,7 +285,7 @@ export class SafeMethodCall extends AST { export class FunctionCall extends AST { constructor(public target: AST, public args: List) { super(); } - eval(context, locals) { + eval(context, locals: Locals) { var obj: any = this.target.eval(context, locals); if (!(obj instanceof Function)) { throw new BaseException(`${obj} is not a function`); @@ -298,11 +299,11 @@ export class FunctionCall extends AST { export class ASTWithSource extends AST { 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; } - 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); } @@ -413,7 +414,7 @@ var _evalListCache = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ]; -function evalList(context, locals, exps: List) { +function evalList(context, locals: Locals, exps: List) { var length = exps.length; if (length > 10) { throw new BaseException("Cannot have more than 10 argument"); diff --git a/modules/angular2/src/change_detection/pipes/iterable_changes.ts b/modules/angular2/src/change_detection/pipes/iterable_changes.ts index dd8d65d2d2..fba550cf0c 100644 --- a/modules/angular2/src/change_detection/pipes/iterable_changes.ts +++ b/modules/angular2/src/change_detection/pipes/iterable_changes.ts @@ -609,7 +609,7 @@ class _DuplicateItemRecordList { } class _DuplicateMap { - map: Map; + map: Map; constructor() { this.map = MapWrapper.create(); } put(record: CollectionChangeRecord) { diff --git a/modules/angular2/src/core/compiler/element_injector.ts b/modules/angular2/src/core/compiler/element_injector.ts index 2de8649b77..bc735e9656 100644 --- a/modules/angular2/src/core/compiler/element_injector.ts +++ b/modules/angular2/src/core/compiler/element_injector.ts @@ -150,7 +150,7 @@ export class TreeNode> { get parent() { return this._parent; } // TODO(rado): replace with a function call, does too much work for a getter. - get children() { + get children(): TreeNode[] { var res = []; var child = this._head; while (child != null) { diff --git a/modules/angular2/src/forms/directives/ng_model.ts b/modules/angular2/src/forms/directives/ng_model.ts index a769a798c3..14072b9647 100644 --- a/modules/angular2/src/forms/directives/ng_model.ts +++ b/modules/angular2/src/forms/directives/ng_model.ts @@ -9,8 +9,7 @@ import {NgControl} from './ng_control'; import {Control} from '../model'; import {setUpControl} from './shared'; -const formControlBinding = - CONST_EXPR(new Binding(NgControl, {toAlias: forwardRef(() => NgModel)})); +const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRef(() => NgModel)})); /** * Binds a domain model to the form. diff --git a/modules/angular2/src/render/dom/events/hammer_gestures.ts b/modules/angular2/src/render/dom/events/hammer_gestures.ts index 5bfaad4322..39c870d858 100644 --- a/modules/angular2/src/render/dom/events/hammer_gestures.ts +++ b/modules/angular2/src/render/dom/events/hammer_gestures.ts @@ -1,4 +1,4 @@ -/// +/// import {HammerGesturesPluginCommon} from './hammer_common'; import {isPresent, BaseException} from 'angular2/src/facade/lang'; diff --git a/modules/angular2/src/router/router.ts b/modules/angular2/src/router/router.ts index b060bbda4e..6934ba2775 100644 --- a/modules/angular2/src/router/router.ts +++ b/modules/angular2/src/router/router.ts @@ -90,8 +90,8 @@ export class Router { */ config(config: any): Promise { if (config instanceof List) { - config.forEach( - (configObject) => { this._registry.config(this.hostComponent, configObject); }); + (>config) + .forEach((configObject) => { this._registry.config(this.hostComponent, configObject); }); } else { this._registry.config(this.hostComponent, config); } diff --git a/modules/angular2/src/test_lib/test_bed.ts b/modules/angular2/src/test_lib/test_bed.ts index e2c347f658..b85cfb8648 100644 --- a/modules/angular2/src/test_lib/test_bed.ts +++ b/modules/angular2/src/test_lib/test_bed.ts @@ -128,7 +128,7 @@ export class ViewProxy { this._view.changeDetector.checkNoChanges(); } - querySelector(selector) { return queryView(this._view, selector); } + querySelector(selector): any { return queryView(this._view, selector); } destroy() { this._componentRef.dispose(); } diff --git a/modules/angular2/src/test_lib/utils.ts b/modules/angular2/src/test_lib/utils.ts index c0524ede63..fef4a73859 100644 --- a/modules/angular2/src/test_lib/utils.ts +++ b/modules/angular2/src/test_lib/utils.ts @@ -23,7 +23,7 @@ export function viewRootNodes(view): List { return resolveInternalDomView(view.render).rootNodes; } -export function queryView(view, selector: string) { +export function queryView(view, selector: string): any { var rootNodes = viewRootNodes(view); for (var i = 0; i < rootNodes.length; ++i) { var res = DOM.querySelector(rootNodes[i], selector); diff --git a/modules/angular2/test/change_detection/parser/locals_spec.ts b/modules/angular2/test/change_detection/parser/locals_spec.ts index 9e4f2a6485..b1c796f477 100644 --- a/modules/angular2/test/change_detection/parser/locals_spec.ts +++ b/modules/angular2/test/change_detection/parser/locals_spec.ts @@ -6,7 +6,7 @@ import {MapWrapper} from 'angular2/src/facade/collection'; export function main() { describe('Locals', () => { - var locals; + var locals: Locals; beforeEach(() => { locals = new Locals(null, MapWrapper.createFromPairs([['key', 'value'], ['nullKey', null]])); }); diff --git a/modules/angular2/test/change_detection/pipes/iterable_changes_spec.ts b/modules/angular2/test/change_detection/pipes/iterable_changes_spec.ts index a374106ace..76d2915ffd 100644 --- a/modules/angular2/test/change_detection/pipes/iterable_changes_spec.ts +++ b/modules/angular2/test/change_detection/pipes/iterable_changes_spec.ts @@ -12,7 +12,6 @@ export function main() { describe('collection_changes', function() { describe('CollectionChanges', function() { var changes; - var l; beforeEach(() => { changes = new IterableChanges(); }); @@ -26,7 +25,7 @@ export function main() { }); it('should support iterables', () => { - l = new TestIterable(); + let l = new TestIterable(); changes.check(l); expect(changes.toString()).toEqual(iterableChangesAsString({collection: []})); @@ -49,17 +48,17 @@ export function main() { }); it('should detect additions', () => { - l = []; + let l = []; changes.check(l); expect(changes.toString()).toEqual(iterableChangesAsString({collection: []})); - ListWrapper.push(l, 'a'); + l.push('a'); changes.check(l); expect(changes.toString()) .toEqual( iterableChangesAsString({collection: ['a[null->0]'], additions: ['a[null->0]']})); - ListWrapper.push(l, 'b'); + l.push('b'); changes.check(l); expect(changes.toString()) .toEqual(iterableChangesAsString( @@ -67,7 +66,7 @@ export function main() { }); it('should support changing the reference', () => { - l = [0]; + let l = [0]; changes.check(l); l = [1, 0]; @@ -92,12 +91,12 @@ export function main() { }); it('should handle swapping element', () => { - l = [1, 2]; + let l = [1, 2]; changes.check(l); ListWrapper.clear(l); - ListWrapper.push(l, 2); - ListWrapper.push(l, 1); + l.push(2); + l.push(1); changes.check(l); expect(changes.toString()) .toEqual(iterableChangesAsString({ @@ -108,7 +107,7 @@ export function main() { }); it('should handle swapping element', () => { - l = ['a', 'b', 'c']; + let l = ['a', 'b', 'c']; changes.check(l); ListWrapper.removeAt(l, 1); @@ -122,7 +121,7 @@ export function main() { })); ListWrapper.removeAt(l, 1); - ListWrapper.push(l, 'a'); + l.push('a'); changes.check(l); expect(changes.toString()) .toEqual(iterableChangesAsString({ @@ -133,23 +132,23 @@ export function main() { }); it('should detect changes in list', () => { - l = []; + let l = []; changes.check(l); - ListWrapper.push(l, 'a'); + l.push('a'); changes.check(l); expect(changes.toString()) .toEqual( iterableChangesAsString({collection: ['a[null->0]'], additions: ['a[null->0]']})); - ListWrapper.push(l, 'b'); + l.push('b'); changes.check(l); expect(changes.toString()) .toEqual(iterableChangesAsString( {collection: ['a', 'b[null->1]'], previous: ['a'], additions: ['b[null->1]']})); - ListWrapper.push(l, 'c'); - ListWrapper.push(l, 'd'); + l.push('c'); + l.push('d'); changes.check(l); expect(changes.toString()) .toEqual(iterableChangesAsString({ @@ -169,10 +168,10 @@ export function main() { })); ListWrapper.clear(l); - ListWrapper.push(l, 'd'); - ListWrapper.push(l, 'c'); - ListWrapper.push(l, 'b'); - ListWrapper.push(l, 'a'); + l.push('d'); + l.push('c'); + l.push('b'); + l.push('a'); changes.check(l); expect(changes.toString()) .toEqual(iterableChangesAsString({ @@ -184,7 +183,7 @@ export function main() { }); it('should test string by value rather than by reference (Dart)', () => { - l = ['a', 'boo']; + let l = ['a', 'boo']; changes.check(l); var b = 'b'; @@ -196,7 +195,7 @@ export function main() { }); it('should ignore [NaN] != [NaN] (JS)', () => { - l = [NumberWrapper.NaN]; + let l = [NumberWrapper.NaN]; changes.check(l); changes.check(l); expect(changes.toString()) @@ -205,7 +204,7 @@ export function main() { }); it('should detect [NaN] moves', () => { - l = [NumberWrapper.NaN, NumberWrapper.NaN]; + let l = [NumberWrapper.NaN, NumberWrapper.NaN]; changes.check(l); ListWrapper.insert(l, 0, 'foo'); @@ -220,7 +219,7 @@ export function main() { }); it('should remove and add same item', () => { - l = ['a', 'b', 'c']; + let l = ['a', 'b', 'c']; changes.check(l); ListWrapper.removeAt(l, 1); @@ -245,7 +244,7 @@ export function main() { }); it('should support duplicates', () => { - l = ['a', 'a', 'a', 'b', 'b']; + let l = ['a', 'a', 'a', 'b', 'b']; changes.check(l); ListWrapper.removeAt(l, 0); @@ -260,7 +259,7 @@ export function main() { }); it('should support insertions/moves', () => { - l = ['a', 'a', 'b', 'b']; + let l = ['a', 'a', 'b', 'b']; changes.check(l); ListWrapper.insert(l, 0, 'b'); @@ -275,13 +274,13 @@ export function main() { }); it('should not report unnecessary moves', () => { - l = ['a', 'b', 'c']; + let l = ['a', 'b', 'c']; changes.check(l); ListWrapper.clear(l); - ListWrapper.push(l, 'b'); - ListWrapper.push(l, 'a'); - ListWrapper.push(l, 'c'); + l.push('b'); + l.push('a'); + l.push('c'); changes.check(l); expect(changes.toString()) .toEqual(iterableChangesAsString({ diff --git a/modules/angular2/test/core/application_spec.ts b/modules/angular2/test/core/application_spec.ts index ea363b4c40..3d5726dca3 100644 --- a/modules/angular2/test/core/application_spec.ts +++ b/modules/angular2/test/core/application_spec.ts @@ -16,7 +16,7 @@ import {bootstrap} from 'angular2/src/core/application'; import {Component, Directive, View} from 'angular2/annotations'; import {DOM} from 'angular2/src/dom/dom_adapter'; 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 {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability'; import {DOCUMENT_TOKEN} from 'angular2/src/render/dom/dom_renderer'; @@ -181,7 +181,7 @@ export function main() { PromiseWrapper.all([refPromise1, refPromise2]) .then((refs) => { - var registry = refs[0].injector.get(TestabilityRegistry); + var registry = (refs[0].injector).get(TestabilityRegistry); PromiseWrapper.all([ refs[0] .injector.asyncGet(Testability), diff --git a/modules/angular2/test/core/compiler/dynamic_component_loader_spec.ts b/modules/angular2/test/core/compiler/dynamic_component_loader_spec.ts index 6fedaead39..9c9305d81c 100644 --- a/modules/angular2/test/core/compiler/dynamic_component_loader_spec.ts +++ b/modules/angular2/test/core/compiler/dynamic_component_loader_spec.ts @@ -29,7 +29,11 @@ import {AppViewManager} from 'angular2/src/core/compiler/view_manager'; export function main() { describe('DynamicComponentLoader', function() { 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({ template: '', directives: [DynamicComp] @@ -48,7 +52,7 @@ export function main() { })); it('should inject dependencies of the dynamically-loaded component', - inject([TestBed, AsyncTestCompleter], (tb, async) => { + ijTestBed((tb: TestBed, async) => { tb.overrideView(MyComp, new viewAnn.View({ template: '', directives: [DynamicComp] @@ -65,7 +69,7 @@ export function main() { })); 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({ template: '
', @@ -103,7 +107,8 @@ export function main() { describe("loading next to an existing location", () => { it('should work', - inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb, async) => { + inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb: TestBed, + async) => { tb.overrideView( MyComp, new viewAnn.View( @@ -121,7 +126,8 @@ export function main() { })); it('should return a disposable component ref', - inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb, async) => { + inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb: TestBed, + async) => { tb.overrideView( MyComp, new viewAnn.View( @@ -148,7 +154,8 @@ export function main() { })); it('should update host properties', - inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb, async) => { + inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb: TestBed, + async) => { tb.overrideView( MyComp, new viewAnn.View( @@ -175,7 +182,7 @@ export function main() { describe('loading into a new location', () => { 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({ template: '', directives: [ImperativeViewComponentUsingNgComponent] @@ -206,10 +213,9 @@ export function main() { }); describe('loadAsRoot', () => { - it('should allow to create, update and destroy components', inject([TestBed, AsyncTestCompleter, DynamicComponentLoader, DOCUMENT_TOKEN, Injector], - (tb, async, dcl, doc, injector) => { + (tb: TestBed, async, dcl, doc, injector) => { var rootEl = el(''); DOM.appendChild(doc.body, rootEl); dcl.loadAsRoot(ChildComp, null, injector) diff --git a/modules/angular2/test/core/compiler/element_injector_spec.ts b/modules/angular2/test/core/compiler/element_injector_spec.ts index 0584e3cf46..f708531b9e 100644 --- a/modules/angular2/test/core/compiler/element_injector_spec.ts +++ b/modules/angular2/test/core/compiler/element_injector_spec.ts @@ -236,7 +236,7 @@ export function main() { return ProtoElementInjector.create(parent, index, directiveBinding, hasShadowRoot, distance); } - function humanize(tree, names: List>) { + function humanize(tree: TreeNode, names: List>) { var lookupName = (item) => ListWrapper.last(ListWrapper.find(names, (pair) => pair[0] === item)); diff --git a/modules/angular2/test/core/compiler/integration_spec.ts b/modules/angular2/test/core/compiler/integration_spec.ts index 8b43b1b3bc..65e5460835 100644 --- a/modules/angular2/test/core/compiler/integration_spec.ts +++ b/modules/angular2/test/core/compiler/integration_spec.ts @@ -83,7 +83,8 @@ export function main() { 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: '
{{ctxProp}}
'})); tb.createView(MyComp, {context: ctx}) .then((view) => { @@ -96,7 +97,7 @@ export function main() { })); it('should consume element binding changes', - inject([TestBed, AsyncTestCompleter], (tb, async) => { + inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => { tb.overrideView(MyComp, new viewAnn.View({template: '
'})); tb.createView(MyComp, {context: ctx}) @@ -111,7 +112,7 @@ export function main() { })); it('should consume binding to aria-* attributes', - inject([TestBed, AsyncTestCompleter], (tb, async) => { + inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => { tb.overrideView(MyComp, new viewAnn.View({template: '
'})); @@ -133,7 +134,7 @@ export function main() { })); 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, new viewAnn.View({template: '
'})); @@ -152,7 +153,7 @@ export function main() { })); 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, new viewAnn.View({template: ''})); @@ -171,7 +172,7 @@ export function main() { })); it('should consume binding to inner-html', - inject([TestBed, AsyncTestCompleter], (tb, async) => { + inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => { tb.overrideView(MyComp, new viewAnn.View({template: '
'})); @@ -191,7 +192,7 @@ export function main() { })); it('should ignore bindings to unknown properties', - inject([TestBed, AsyncTestCompleter], (tb, async) => { + inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => { tb.overrideView(MyComp, new viewAnn.View({template: '
'})); @@ -207,7 +208,7 @@ export function main() { })); it('should consume directive watch expression change.', - inject([TestBed, AsyncTestCompleter], (tb, async) => { + inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => { var tpl = '
' + '
' + '
' + @@ -243,7 +244,7 @@ export function main() { }); 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({ template: '', @@ -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( MyComp, new viewAnn.View({template: '', directives: [ChildComp]})); @@ -281,7 +283,7 @@ export function main() { // GH issue 328 - https://github.com/angular/angular/issues/328 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({ template: '', directives: [MyDir, ChildComp] @@ -302,7 +304,7 @@ export function main() { })); 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({ // No attribute "el-prop" specified. template: '

', @@ -313,7 +315,7 @@ export function main() { })); it('should support directives where a selector matches property binding', - inject([TestBed, AsyncTestCompleter], (tb, async) => { + inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => { tb.overrideView( MyComp, new viewAnn.View({template: '

', directives: [IdDir]})); @@ -334,7 +336,7 @@ export function main() { })); it('should allow specifying directives as bindings', - inject([TestBed, AsyncTestCompleter], (tb, async) => { + inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => { tb.overrideView(MyComp, new viewAnn.View({ template: '', directives: [bind(ChildComp).toClass(ChildComp)] @@ -350,7 +352,7 @@ export function main() { })); 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({ template: '
', directives: [bind(PublicApi).toClass(PrivateImpl), NeedsPublicApi] @@ -360,7 +362,7 @@ export function main() { })); it('should support template directives via `