chore(forms): fix implicit any

This commit is contained in:
Kara Erickson 2016-06-08 17:08:59 -07:00
parent 4c39eace52
commit e213939f28
5 changed files with 117 additions and 117 deletions

View File

@ -44,10 +44,10 @@ import {PromiseWrapper} from '../../src/facade/promise';
import {SimpleChange} from '@angular/core/src/change_detection'; import {SimpleChange} from '@angular/core/src/change_detection';
class DummyControlValueAccessor implements ControlValueAccessor { class DummyControlValueAccessor implements ControlValueAccessor {
writtenValue; writtenValue: any /** TODO #9100 */;
registerOnChange(fn) {} registerOnChange(fn: any /** TODO #9100 */) {}
registerOnTouched(fn) {} registerOnTouched(fn: any /** TODO #9100 */) {}
writeValue(obj: any): void { this.writtenValue = obj; } writeValue(obj: any): void { this.writtenValue = obj; }
} }
@ -56,8 +56,8 @@ class CustomValidatorDirective implements Validator {
validate(c: Control): {[key: string]: any} { return {"custom": true}; } validate(c: Control): {[key: string]: any} { return {"custom": true}; }
} }
function asyncValidator(expected, timeout = 0) { function asyncValidator(expected: any /** TODO #9100 */, timeout = 0) {
return (c) => { return (c: any /** TODO #9100 */) => {
var completer = PromiseWrapper.completer(); var completer = PromiseWrapper.completer();
var res = c.value != expected ? {"async": true} : null; var res = c.value != expected ? {"async": true} : null;
if (timeout == 0) { if (timeout == 0) {
@ -120,14 +120,14 @@ export function main() {
describe("composeValidators", () => { describe("composeValidators", () => {
it("should compose functions", () => { it("should compose functions", () => {
var dummy1 = (_) => ({"dummy1": true}); var dummy1 = (_: any /** TODO #9100 */) => ({"dummy1": true});
var dummy2 = (_) => ({"dummy2": true}); var dummy2 = (_: any /** TODO #9100 */) => ({"dummy2": true});
var v = composeValidators([dummy1, dummy2]); var v = composeValidators([dummy1, dummy2]);
expect(v(new Control(""))).toEqual({"dummy1": true, "dummy2": true}); expect(v(new Control(""))).toEqual({"dummy1": true, "dummy2": true});
}); });
it("should compose validator directives", () => { it("should compose validator directives", () => {
var dummy1 = (_) => ({"dummy1": true}); var dummy1 = (_: any /** TODO #9100 */) => ({"dummy1": true});
var v = composeValidators([dummy1, new CustomValidatorDirective()]); var v = composeValidators([dummy1, new CustomValidatorDirective()]);
expect(v(new Control(""))).toEqual({"dummy1": true, "custom": true}); expect(v(new Control(""))).toEqual({"dummy1": true, "custom": true});
}); });
@ -135,9 +135,9 @@ export function main() {
}); });
describe("NgFormModel", () => { describe("NgFormModel", () => {
var form; var form: any /** TODO #9100 */;
var formModel: ControlGroup; var formModel: ControlGroup;
var loginControlDir; var loginControlDir: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
form = new NgFormModel([], []); form = new NgFormModel([], []);
@ -215,7 +215,7 @@ export function main() {
}); });
describe("addControlGroup", () => { describe("addControlGroup", () => {
var matchingPasswordsValidator = (g) => { var matchingPasswordsValidator = (g: any /** TODO #9100 */) => {
if (g.controls["password"].value != g.controls["passwordConfirm"].value) { if (g.controls["password"].value != g.controls["passwordConfirm"].value) {
return {"differentPasswords": true}; return {"differentPasswords": true};
} else { } else {
@ -268,7 +268,7 @@ export function main() {
}); });
it("should set up a sync validator", () => { it("should set up a sync validator", () => {
var formValidator = (c) => ({"custom": true}); var formValidator = (c: any /** TODO #9100 */) => ({"custom": true});
var f = new NgFormModel([formValidator], []); var f = new NgFormModel([formValidator], []);
f.form = formModel; f.form = formModel;
f.ngOnChanges({"form": new SimpleChange(null, null)}); f.ngOnChanges({"form": new SimpleChange(null, null)});
@ -289,10 +289,10 @@ export function main() {
}); });
describe("NgForm", () => { describe("NgForm", () => {
var form; var form: any /** TODO #9100 */;
var formModel: ControlGroup; var formModel: ControlGroup;
var loginControlDir; var loginControlDir: any /** TODO #9100 */;
var personControlGroupDir; var personControlGroupDir: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
form = new NgForm([], []); form = new NgForm([], []);
@ -348,7 +348,7 @@ export function main() {
}); });
it("should set up sync validator", fakeAsync(() => { it("should set up sync validator", fakeAsync(() => {
var formValidator = (c) => ({"custom": true}); var formValidator = (c: any /** TODO #9100 */) => ({"custom": true});
var f = new NgForm([formValidator], []); var f = new NgForm([formValidator], []);
tick(); tick();
@ -366,8 +366,8 @@ export function main() {
}); });
describe("NgControlGroup", () => { describe("NgControlGroup", () => {
var formModel; var formModel: any /** TODO #9100 */;
var controlGroupDir; var controlGroupDir: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
formModel = new ControlGroup({"login": new Control(null)}); formModel = new ControlGroup({"login": new Control(null)});
@ -391,9 +391,9 @@ export function main() {
}); });
describe("NgFormControl", () => { describe("NgFormControl", () => {
var controlDir; var controlDir: any /** TODO #9100 */;
var control; var control: any /** TODO #9100 */;
var checkProperties = function(control) { var checkProperties = function(control: any /** TODO #9100 */) {
expect(controlDir.control).toBe(control); expect(controlDir.control).toBe(control);
expect(controlDir.value).toBe(control.value); expect(controlDir.value).toBe(control.value);
expect(controlDir.valid).toBe(control.valid); expect(controlDir.valid).toBe(control.valid);
@ -433,7 +433,7 @@ export function main() {
}); });
describe("NgModel", () => { describe("NgModel", () => {
var ngModel; var ngModel: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
ngModel = ngModel =
@ -468,8 +468,8 @@ export function main() {
}); });
describe("NgControlName", () => { describe("NgControlName", () => {
var formModel; var formModel: any /** TODO #9100 */;
var controlNameDir; var controlNameDir: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
formModel = new Control("name"); formModel = new Control("name");

View File

@ -12,11 +12,11 @@ import {Control, FormBuilder} from '@angular/common';
import {PromiseWrapper} from '../../src/facade/promise'; import {PromiseWrapper} from '../../src/facade/promise';
export function main() { export function main() {
function syncValidator(_) { return null; } function syncValidator(_: any /** TODO #9100 */): any /** TODO #9100 */ { return null; }
function asyncValidator(_) { return PromiseWrapper.resolve(null); } function asyncValidator(_: any /** TODO #9100 */) { return PromiseWrapper.resolve(null); }
describe("Form Builder", () => { describe("Form Builder", () => {
var b; var b: any /** TODO #9100 */;
beforeEach(() => { b = new FormBuilder(); }); beforeEach(() => { b = new FormBuilder(); });

View File

@ -41,7 +41,7 @@ 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([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<input type="text" ngControl="login"> <input type="text" ngControl="login">
</div>`; </div>`;
@ -60,7 +60,7 @@ export function main() {
})); }));
it("should throw if a form isn't passed into ngFormModel", it("should throw if a form isn't passed into ngFormModel",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<input type="text" ngControl="login"> <input type="text" ngControl="login">
</div>`; </div>`;
@ -75,7 +75,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([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var form = new ControlGroup({"login": new Control("oldValue")}); var form = new ControlGroup({"login": new Control("oldValue")});
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
@ -98,7 +98,7 @@ export function main() {
})); }));
it("should ignore the change event for <input type=text>", it("should ignore the change event for <input type=text>",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var form = new ControlGroup({"login": new Control("oldValue")}); var form = new ControlGroup({"login": new Control("oldValue")});
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
@ -194,7 +194,7 @@ export function main() {
}))); })));
it("should work with single controls", it("should work with single controls",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var control = new Control("loginValue"); var control = new Control("loginValue");
var t = `<div><input type="text" [ngFormControl]="form"></div>`; var t = `<div><input type="text" [ngFormControl]="form"></div>`;
@ -217,7 +217,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([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<input type="text" ngControl="login"> <input type="text" ngControl="login">
</div>`; </div>`;
@ -240,7 +240,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([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var login = new Control("oldValue"); var login = new Control("oldValue");
var form = new ControlGroup({"login": login}); var form = new ControlGroup({"login": login});
@ -265,7 +265,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([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var login = new Control("oldValue"); var login = new Control("oldValue");
var form = new ControlGroup({"login": login}); var form = new ControlGroup({"login": login});
@ -292,7 +292,7 @@ export function main() {
describe("different control types", () => { describe("different control types", () => {
it("should support <input type=text>", it("should support <input type=text>",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<input type="text" ngControl="text"> <input type="text" ngControl="text">
</div>`; </div>`;
@ -316,7 +316,7 @@ export function main() {
})); }));
it("should support <input> without type", it("should support <input> without type",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<input ngControl="text"> <input ngControl="text">
</div>`; </div>`;
@ -339,7 +339,7 @@ export function main() {
})); }));
it("should support <textarea>", it("should support <textarea>",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<textarea ngControl="text"></textarea> <textarea ngControl="text"></textarea>
</div>`; </div>`;
@ -363,7 +363,7 @@ export function main() {
})); }));
it("should support <type=checkbox>", it("should support <type=checkbox>",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<input type="checkbox" ngControl="checkbox"> <input type="checkbox" ngControl="checkbox">
</div>`; </div>`;
@ -388,7 +388,7 @@ export function main() {
})); }));
it("should support <type=number>", it("should support <type=number>",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<input type="number" ngControl="num"> <input type="number" ngControl="num">
</div>`; </div>`;
@ -412,7 +412,7 @@ export function main() {
})); }));
it("should support <type=number> when value is cleared in the UI", it("should support <type=number> when value is cleared in the UI",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<input type="number" ngControl="num" required> <input type="number" ngControl="num" required>
</div>`; </div>`;
@ -442,7 +442,7 @@ export function main() {
it("should support <type=number> when value is cleared programmatically", it("should support <type=number> when value is cleared programmatically",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var form = new ControlGroup({"num": new Control(10)}); var form = new ControlGroup({"num": new Control(10)});
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<input type="number" ngControl="num" [(ngModel)]="data"> <input type="number" ngControl="num" [(ngModel)]="data">
@ -463,7 +463,7 @@ export function main() {
})); }));
it("should support <type=radio>", it("should support <type=radio>",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<form [ngFormModel]="form"> var t = `<form [ngFormModel]="form">
<input type="radio" ngControl="foodChicken" name="food"> <input type="radio" ngControl="foodChicken" name="food">
<input type="radio" ngControl="foodFish" name="food"> <input type="radio" ngControl="foodFish" name="food">
@ -494,7 +494,7 @@ export function main() {
describe("should support <select>", () => { describe("should support <select>", () => {
it("with basic selection", it("with basic selection",
inject([TestComponentBuilder, AsyncTestCompleter], inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => { (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<select> var t = `<select>
<option value="SF"></option> <option value="SF"></option>
<option value="NYC"></option> <option value="NYC"></option>
@ -516,7 +516,7 @@ export function main() {
it("with basic selection and value bindings", it("with basic selection and value bindings",
inject([TestComponentBuilder, AsyncTestCompleter], inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => { (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<select> var t = `<select>
<option *ngFor="let city of list" [value]="city['id']"> <option *ngFor="let city of list" [value]="city['id']">
{{ city['name'] }} {{ city['name'] }}
@ -542,7 +542,7 @@ export function main() {
it("with ngControl", it("with ngControl",
inject([TestComponentBuilder, AsyncTestCompleter], inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => { (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<select ngControl="city"> <select ngControl="city">
<option value="SF"></option> <option value="SF"></option>
@ -582,7 +582,7 @@ export function main() {
</select> </select>
</div>`; </div>`;
var fixture; var fixture: any /** TODO #9100 */;
tcb.overrideTemplate(MyComp8, t) tcb.overrideTemplate(MyComp8, t)
.createAsync(MyComp8) .createAsync(MyComp8)
.then((compFixture) => fixture = compFixture); .then((compFixture) => fixture = compFixture);
@ -601,7 +601,7 @@ export function main() {
it("with option values that are objects", it("with option values that are objects",
inject([TestComponentBuilder, AsyncTestCompleter], inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => { (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div> var t = `<div>
<select [(ngModel)]="selectedCity"> <select [(ngModel)]="selectedCity">
<option *ngFor="let c of list" [ngValue]="c">{{c['name']}}</option> <option *ngFor="let c of list" [ngValue]="c">{{c['name']}}</option>
@ -635,7 +635,7 @@ export function main() {
it("when new options are added (selection through the model)", it("when new options are added (selection through the model)",
inject([TestComponentBuilder, AsyncTestCompleter], inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => { (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div> var t = `<div>
<select [(ngModel)]="selectedCity"> <select [(ngModel)]="selectedCity">
<option *ngFor="let c of list" [ngValue]="c">{{c['name']}}</option> <option *ngFor="let c of list" [ngValue]="c">{{c['name']}}</option>
@ -665,7 +665,7 @@ export function main() {
it("when new options are added (selection through the UI)", it("when new options are added (selection through the UI)",
inject([TestComponentBuilder, AsyncTestCompleter], inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => { (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div> var t = `<div>
<select [(ngModel)]="selectedCity"> <select [(ngModel)]="selectedCity">
<option *ngFor="let c of list" [ngValue]="c">{{c['name']}}</option> <option *ngFor="let c of list" [ngValue]="c">{{c['name']}}</option>
@ -698,7 +698,7 @@ export function main() {
it("when options are removed", it("when options are removed",
inject([TestComponentBuilder, AsyncTestCompleter], inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => { (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div> var t = `<div>
<select [(ngModel)]="selectedCity"> <select [(ngModel)]="selectedCity">
<option *ngFor="let c of list" [ngValue]="c">{{c}}</option> <option *ngFor="let c of list" [ngValue]="c">{{c}}</option>
@ -726,7 +726,7 @@ export function main() {
it("when option values change identity while tracking by index", it("when option values change identity while tracking by index",
inject([TestComponentBuilder, AsyncTestCompleter], inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => { (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div> var t = `<div>
<select [(ngModel)]="selectedCity"> <select [(ngModel)]="selectedCity">
<option *ngFor="let c of list; trackBy:customTrackBy" [ngValue]="c">{{c}}</option> <option *ngFor="let c of list; trackBy:customTrackBy" [ngValue]="c">{{c}}</option>
@ -758,7 +758,7 @@ export function main() {
it("with duplicate option values", it("with duplicate option values",
inject([TestComponentBuilder, AsyncTestCompleter], inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => { (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div> var t = `<div>
<select [(ngModel)]="selectedCity"> <select [(ngModel)]="selectedCity">
<option *ngFor="let c of list" [ngValue]="c">{{c}}</option> <option *ngFor="let c of list" [ngValue]="c">{{c}}</option>
@ -789,7 +789,7 @@ export function main() {
it("when option values have same content, but different identities", it("when option values have same content, but different identities",
inject([TestComponentBuilder, AsyncTestCompleter], inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => { (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div> var t = `<div>
<select [(ngModel)]="selectedCity"> <select [(ngModel)]="selectedCity">
<option *ngFor="let c of list" [ngValue]="c">{{c['name']}}</option> <option *ngFor="let c of list" [ngValue]="c">{{c['name']}}</option>
@ -819,7 +819,7 @@ export function main() {
}); });
it("should support custom value accessors", it("should support custom value accessors",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<input type="text" ngControl="name" wrapped-value> <input type="text" ngControl="name" wrapped-value>
</div>`; </div>`;
@ -842,7 +842,7 @@ export function main() {
})); }));
it("should support custom value accessors on non builtin input elements that fire a change event without a 'target' property", it("should support custom value accessors on non builtin input elements that fire a change event without a 'target' property",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
<my-input ngControl="name"></my-input> <my-input ngControl="name"></my-input>
</div>`; </div>`;
@ -870,7 +870,7 @@ export function main() {
describe("validations", () => { describe("validations", () => {
it("should use sync validators defined in html", it("should use sync validators defined in html",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var form = new ControlGroup( var form = new ControlGroup(
{"login": new Control(""), "min": new Control(""), "max": new Control("")}); {"login": new Control(""), "min": new Control(""), "max": new Control("")});
@ -924,7 +924,7 @@ export function main() {
<input type="text" ngControl="login" uniq-login-validator="expected"> <input type="text" ngControl="login" uniq-login-validator="expected">
</div>`; </div>`;
var rootTC; var rootTC: any /** TODO #9100 */;
tcb.overrideTemplate(MyComp8, t).createAsync(MyComp8).then((root) => rootTC = root); tcb.overrideTemplate(MyComp8, t).createAsync(MyComp8).then((root) => rootTC = root);
tick(); tick();
@ -946,7 +946,7 @@ export function main() {
}))); })));
it("should use sync validators defined in the model", it("should use sync validators defined in the model",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var form = new ControlGroup({"login": new Control("aa", Validators.required)}); var form = new ControlGroup({"login": new Control("aa", Validators.required)});
var t = `<div [ngFormModel]="form"> var t = `<div [ngFormModel]="form">
@ -979,7 +979,7 @@ export function main() {
<input type="text" ngControl="login"> <input type="text" ngControl="login">
</div>`; </div>`;
var fixture; var fixture: any /** TODO #9100 */;
tcb.overrideTemplate(MyComp8, t).createAsync(MyComp8).then((root) => fixture = root); tcb.overrideTemplate(MyComp8, t).createAsync(MyComp8).then((root) => fixture = root);
tick(); tick();
@ -1007,7 +1007,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([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var form = var form =
new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})}); new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})});
@ -1030,7 +1030,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([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var form = var form =
new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})}); new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})});
@ -1141,7 +1141,7 @@ export function main() {
}))); })));
it("should not create a template-driven form when ngNoForm is used", it("should not create a template-driven form when ngNoForm is used",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<form ngNoForm> var t = `<form ngNoForm>
</form>`; </form>`;
@ -1322,7 +1322,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([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var form = new Control("", Validators.required); var form = new Control("", Validators.required);
var t = `<div><input type="text" [ngFormControl]="form"></div>`; var t = `<div><input type="text" [ngFormControl]="form"></div>`;
@ -1353,7 +1353,7 @@ export function main() {
})); }));
it("should work with complex model-driven forms", it("should work with complex model-driven forms",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var form = new ControlGroup({"name": new Control("", Validators.required)}); var form = new ControlGroup({"name": new Control("", Validators.required)});
var t = `<form [ngFormModel]="form"><input type="text" ngControl="name"></form>`; var t = `<form [ngFormModel]="form"><input type="text" ngControl="name"></form>`;
@ -1384,7 +1384,7 @@ export function main() {
})); }));
it("should work with ngModel", it("should work with ngModel",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
var t = `<div><input [(ngModel)]="name" required></div>`; var t = `<div><input [(ngModel)]="name" required></div>`;
tcb.overrideTemplate(MyComp8, t) tcb.overrideTemplate(MyComp8, t)
@ -1486,17 +1486,17 @@ export function main() {
host: {'(input)': 'handleOnInput($event.target.value)', '[value]': 'value'} host: {'(input)': 'handleOnInput($event.target.value)', '[value]': 'value'}
}) })
class WrappedValue implements ControlValueAccessor { class WrappedValue implements ControlValueAccessor {
value; value: any /** TODO #9100 */;
onChange: Function; onChange: Function;
constructor(cd: NgControl) { cd.valueAccessor = this; } constructor(cd: NgControl) { cd.valueAccessor = this; }
writeValue(value) { this.value = `!${value}!`; } writeValue(value: any /** TODO #9100 */) { this.value = `!${value}!`; }
registerOnChange(fn) { this.onChange = fn; } registerOnChange(fn: any /** TODO #9100 */) { this.onChange = fn; }
registerOnTouched(fn) {} registerOnTouched(fn: any /** TODO #9100 */) {}
handleOnInput(value) { this.onChange(value.substring(1, value.length - 1)); } handleOnInput(value: any /** TODO #9100 */) { this.onChange(value.substring(1, value.length - 1)); }
} }
@Component({selector: "my-input", template: ''}) @Component({selector: "my-input", template: ''})
@ -1506,11 +1506,11 @@ class MyInput implements ControlValueAccessor {
constructor(cd: NgControl) { cd.valueAccessor = this; } constructor(cd: NgControl) { cd.valueAccessor = this; }
writeValue(value) { this.value = `!${value}!`; } writeValue(value: any /** TODO #9100 */) { this.value = `!${value}!`; }
registerOnChange(fn) { ObservableWrapper.subscribe(this.onInput, fn); } registerOnChange(fn: any /** TODO #9100 */) { ObservableWrapper.subscribe(this.onInput, fn); }
registerOnTouched(fn) {} registerOnTouched(fn: any /** TODO #9100 */) {}
dispatchChangeEvent() { dispatchChangeEvent() {
ObservableWrapper.callEmit(this.onInput, this.value.substring(1, this.value.length - 1)); ObservableWrapper.callEmit(this.onInput, this.value.substring(1, this.value.length - 1));
@ -1518,7 +1518,7 @@ class MyInput implements ControlValueAccessor {
} }
function uniqLoginAsyncValidator(expectedValue: string) { function uniqLoginAsyncValidator(expectedValue: string) {
return (c) => { return (c: any /** TODO #9100 */) => {
var completer = PromiseWrapper.completer(); var completer = PromiseWrapper.completer();
var res = (c.value == expectedValue) ? null : {"uniqLogin": true}; var res = (c.value == expectedValue) ? null : {"uniqLogin": true};
completer.resolve(res); completer.resolve(res);
@ -1550,9 +1550,9 @@ class LoginIsEmptyValidator {
] ]
}) })
class UniqLoginValidator implements Validator { class UniqLoginValidator implements Validator {
@Input('uniq-login-validator') expected; @Input('uniq-login-validator') expected: any /** TODO #9100 */;
validate(c) { return uniqLoginAsyncValidator(this.expected)(c); } validate(c: any /** TODO #9100 */) { return uniqLoginAsyncValidator(this.expected)(c); }
} }
@Component({ @Component({
@ -1577,7 +1577,7 @@ class MyComp8 {
customTrackBy(index: number, obj: any): number { return index; }; customTrackBy(index: number, obj: any): number { return index; };
} }
function sortedClassList(el) { function sortedClassList(el: any /** TODO #9100 */) {
var l = getDOM().classList(el); var l = getDOM().classList(el);
ListWrapper.sort(l); ListWrapper.sort(l);
return l; return l;

View File

@ -17,10 +17,10 @@ import {PromiseWrapper} from '../../src/facade/promise';
import {TimerWrapper, ObservableWrapper, EventEmitter} from '../../src/facade/async'; import {TimerWrapper, ObservableWrapper, EventEmitter} from '../../src/facade/async';
export function main() { export function main() {
function asyncValidator(expected, timeouts = /*@ts2dart_const*/ {}) { function asyncValidator(expected: any /** TODO #9100 */, timeouts = /*@ts2dart_const*/ {}) {
return (c) => { return (c: any /** TODO #9100 */) => {
var completer = PromiseWrapper.completer(); var completer = PromiseWrapper.completer();
var t = isPresent(timeouts[c.value]) ? timeouts[c.value] : 0; var t = isPresent((timeouts as any /** TODO #9100 */)[c.value]) ? (timeouts as any /** TODO #9100 */)[c.value] : 0;
var res = c.value != expected ? {"async": true} : null; var res = c.value != expected ? {"async": true} : null;
if (t == 0) { if (t == 0) {
@ -33,7 +33,7 @@ export function main() {
}; };
} }
function asyncValidatorReturningObservable(c) { function asyncValidatorReturningObservable(c: any /** TODO #9100 */) {
var e = new EventEmitter(); var e = new EventEmitter();
PromiseWrapper.scheduleMicrotask(() => ObservableWrapper.callEmit(e, {"async": true})); PromiseWrapper.scheduleMicrotask(() => ObservableWrapper.callEmit(e, {"async": true}));
return e; return e;
@ -140,7 +140,7 @@ export function main() {
}); });
describe("updateValue", () => { describe("updateValue", () => {
var g, c; var g: any /** TODO #9100 */, c: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
c = new Control("oldValue"); c = new Control("oldValue");
g = new ControlGroup({"one": c}); g = new ControlGroup({"one": c});
@ -152,8 +152,8 @@ export function main() {
}); });
it("should invoke ngOnChanges if it is present", () => { it("should invoke ngOnChanges if it is present", () => {
var ngOnChanges; var ngOnChanges: any /** TODO #9100 */;
c.registerOnChange((v) => ngOnChanges = ["invoked", v]); c.registerOnChange((v: any /** TODO #9100 */) => ngOnChanges = ["invoked", v]);
c.updateValue("newValue"); c.updateValue("newValue");
@ -161,8 +161,8 @@ export function main() {
}); });
it("should not invoke on change when explicitly specified", () => { it("should not invoke on change when explicitly specified", () => {
var onChange = null; var onChange: any /** TODO #9100 */ = null;
c.registerOnChange((v) => onChange = ["invoked", v]); c.registerOnChange((v: any /** TODO #9100 */) => onChange = ["invoked", v]);
c.updateValue("newValue", {emitModelToViewChange: false}); c.updateValue("newValue", {emitModelToViewChange: false});
@ -197,12 +197,12 @@ export function main() {
}); });
describe("valueChanges & statusChanges", () => { describe("valueChanges & statusChanges", () => {
var c; var c: any /** TODO #9100 */;
beforeEach(() => { c = new Control("old", Validators.required); }); beforeEach(() => { c = new Control("old", Validators.required); });
it("should fire an event after the value has been updated", it("should fire an event after the value has been updated",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
ObservableWrapper.subscribe(c.valueChanges, (value) => { ObservableWrapper.subscribe(c.valueChanges, (value) => {
expect(c.value).toEqual('new'); expect(c.value).toEqual('new');
expect(value).toEqual('new'); expect(value).toEqual('new');
@ -224,7 +224,7 @@ export function main() {
it("should fire an event after the status has been updated to pending", fakeAsync(() => { it("should fire an event after the status has been updated to pending", fakeAsync(() => {
var c = new Control("old", Validators.required, asyncValidator("expected")); var c = new Control("old", Validators.required, asyncValidator("expected"));
var log = []; var log: any[] /** TODO #9100 */ = [];
ObservableWrapper.subscribe(c.valueChanges, (value) => log.push(`value: '${value}'`)); ObservableWrapper.subscribe(c.valueChanges, (value) => log.push(`value: '${value}'`));
ObservableWrapper.subscribe(c.statusChanges, ObservableWrapper.subscribe(c.statusChanges,
(status) => log.push(`status: '${status}'`)); (status) => log.push(`status: '${status}'`));
@ -253,8 +253,8 @@ export function main() {
// TODO: remove the if statement after making observable delivery sync // TODO: remove the if statement after making observable delivery sync
if (!IS_DART) { if (!IS_DART) {
it("should update set errors and status before emitting an event", it("should update set errors and status before emitting an event",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
c.valueChanges.subscribe(value => { c.valueChanges.subscribe((value: any /** TODO #9100 */) => {
expect(c.valid).toEqual(false); expect(c.valid).toEqual(false);
expect(c.errors).toEqual({"required": true}); expect(c.errors).toEqual({"required": true});
async.done(); async.done();
@ -263,7 +263,7 @@ export function main() {
})); }));
} }
it("should return a cold observable", inject([AsyncTestCompleter], (async) => { it("should return a cold observable", inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
c.updateValue("will be ignored"); c.updateValue("will be ignored");
ObservableWrapper.subscribe(c.valueChanges, (value) => { ObservableWrapper.subscribe(c.valueChanges, (value) => {
expect(value).toEqual('new'); expect(value).toEqual('new');
@ -380,7 +380,7 @@ export function main() {
describe("errors", () => { describe("errors", () => {
it("should run the validator when the value changes", () => { it("should run the validator when the value changes", () => {
var simpleValidator = (c) => var simpleValidator = (c: any /** TODO #9100 */) =>
c.controls["one"].value != "correct" ? {"broken": true} : null; c.controls["one"].value != "correct" ? {"broken": true} : null;
var c = new Control(null); var c = new Control(null);
@ -399,7 +399,7 @@ export function main() {
}); });
describe("dirty", () => { describe("dirty", () => {
var c, g; var c: any /** TODO #9100 */, g: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
c = new Control('value'); c = new Control('value');
@ -417,7 +417,7 @@ export function main() {
describe("optional components", () => { describe("optional components", () => {
describe("contains", () => { describe("contains", () => {
var group; var group: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
group = new ControlGroup( group = new ControlGroup(
@ -473,7 +473,7 @@ export function main() {
}); });
describe("valueChanges", () => { describe("valueChanges", () => {
var g, c1, c2; var g: any /** TODO #9100 */, c1: any /** TODO #9100 */, c2: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
c1 = new Control("old1"); c1 = new Control("old1");
@ -482,7 +482,7 @@ export function main() {
}); });
it("should fire an event after the value has been updated", it("should fire an event after the value has been updated",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
ObservableWrapper.subscribe(g.valueChanges, (value) => { ObservableWrapper.subscribe(g.valueChanges, (value) => {
expect(g.value).toEqual({'one': 'new1', 'two': 'old2'}); expect(g.value).toEqual({'one': 'new1', 'two': 'old2'});
expect(value).toEqual({'one': 'new1', 'two': 'old2'}); expect(value).toEqual({'one': 'new1', 'two': 'old2'});
@ -492,7 +492,7 @@ export function main() {
})); }));
it("should fire an event after the control's observable fired an event", it("should fire an event after the control's observable fired an event",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
var controlCallbackIsCalled = false; var controlCallbackIsCalled = false;
ObservableWrapper.subscribe(c1.valueChanges, ObservableWrapper.subscribe(c1.valueChanges,
@ -507,7 +507,7 @@ export function main() {
})); }));
it("should fire an event when a control is excluded", it("should fire an event when a control is excluded",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
ObservableWrapper.subscribe(g.valueChanges, (value) => { ObservableWrapper.subscribe(g.valueChanges, (value) => {
expect(value).toEqual({'one': 'old1'}); expect(value).toEqual({'one': 'old1'});
async.done(); async.done();
@ -517,7 +517,7 @@ export function main() {
})); }));
it("should fire an event when a control is included", it("should fire an event when a control is included",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
g.exclude("two"); g.exclude("two");
ObservableWrapper.subscribe(g.valueChanges, (value) => { ObservableWrapper.subscribe(g.valueChanges, (value) => {
@ -529,8 +529,8 @@ export function main() {
})); }));
it("should fire an event every time a control is updated", it("should fire an event every time a control is updated",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
var loggedValues = []; var loggedValues: any[] /** TODO #9100 */ = [];
ObservableWrapper.subscribe(g.valueChanges, (value) => { ObservableWrapper.subscribe(g.valueChanges, (value) => {
loggedValues.push(value); loggedValues.push(value);
@ -547,7 +547,7 @@ export function main() {
})); }));
xit("should not fire an event when an excluded control is updated", xit("should not fire an event when an excluded control is updated",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
// hard to test without hacking zones // hard to test without hacking zones
})); }));
}); });
@ -609,7 +609,7 @@ export function main() {
describe("ControlArray", () => { describe("ControlArray", () => {
describe("adding/removing", () => { describe("adding/removing", () => {
var a: ControlArray; var a: ControlArray;
var c1, c2, c3; var c1: any /** TODO #9100 */, c2: any /** TODO #9100 */, c3: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
a = new ControlArray([]); a = new ControlArray([]);
@ -658,7 +658,7 @@ export function main() {
describe("errors", () => { describe("errors", () => {
it("should run the validator when the value changes", () => { it("should run the validator when the value changes", () => {
var simpleValidator = (c) => c.controls[0].value != "correct" ? {"broken": true} : null; var simpleValidator = (c: any /** TODO #9100 */) => c.controls[0].value != "correct" ? {"broken": true} : null;
var c = new Control(null); var c = new Control(null);
var g = new ControlArray([c], simpleValidator); var g = new ControlArray([c], simpleValidator);
@ -725,7 +725,7 @@ export function main() {
describe("valueChanges", () => { describe("valueChanges", () => {
var a: ControlArray; var a: ControlArray;
var c1, c2; var c1: any /** TODO #9100 */, c2: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
c1 = new Control("old1"); c1 = new Control("old1");
@ -734,7 +734,7 @@ export function main() {
}); });
it("should fire an event after the value has been updated", it("should fire an event after the value has been updated",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
ObservableWrapper.subscribe(a.valueChanges, (value) => { ObservableWrapper.subscribe(a.valueChanges, (value) => {
expect(a.value).toEqual(['new1', 'old2']); expect(a.value).toEqual(['new1', 'old2']);
expect(value).toEqual(['new1', 'old2']); expect(value).toEqual(['new1', 'old2']);
@ -744,7 +744,7 @@ export function main() {
})); }));
it("should fire an event after the control's observable fired an event", it("should fire an event after the control's observable fired an event",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
var controlCallbackIsCalled = false; var controlCallbackIsCalled = false;
ObservableWrapper.subscribe(c1.valueChanges, ObservableWrapper.subscribe(c1.valueChanges,
@ -759,7 +759,7 @@ export function main() {
})); }));
it("should fire an event when a control is removed", it("should fire an event when a control is removed",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
ObservableWrapper.subscribe(a.valueChanges, (value) => { ObservableWrapper.subscribe(a.valueChanges, (value) => {
expect(value).toEqual(['old1']); expect(value).toEqual(['old1']);
async.done(); async.done();
@ -768,7 +768,7 @@ export function main() {
a.removeAt(1); a.removeAt(1);
})); }));
it("should fire an event when a control is added", inject([AsyncTestCompleter], (async) => { it("should fire an event when a control is added", inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
a.removeAt(1); a.removeAt(1);
ObservableWrapper.subscribe(a.valueChanges, (value) => { ObservableWrapper.subscribe(a.valueChanges, (value) => {

View File

@ -17,7 +17,7 @@ export function main() {
function validator(key: string, error: any) { function validator(key: string, error: any) {
return function(c: AbstractControl) { return function(c: AbstractControl) {
var r = {}; var r = {};
r[key] = error; (r as any /** TODO #9100 */)[key] = error;
return r; return r;
} }
} }
@ -111,8 +111,8 @@ export function main() {
}); });
describe("composeAsync", () => { describe("composeAsync", () => {
function asyncValidator(expected, response) { function asyncValidator(expected: any /** TODO #9100 */, response: any /** TODO #9100 */) {
return (c) => { return (c: any /** TODO #9100 */) => {
var emitter = new EventEmitter(); var emitter = new EventEmitter();
var res = c.value != expected ? response : null; var res = c.value != expected ? response : null;
@ -136,7 +136,7 @@ export function main() {
asyncValidator("expected", {"two": true}) asyncValidator("expected", {"two": true})
]); ]);
var value = null; var value: any /** TODO #9100 */ = null;
(<Promise<any>>c(new Control("invalid"))).then(v => value = v); (<Promise<any>>c(new Control("invalid"))).then(v => value = v);
tick(1); tick(1);
@ -147,7 +147,7 @@ export function main() {
it("should return null when no errors", fakeAsync(() => { it("should return null when no errors", fakeAsync(() => {
var c = Validators.composeAsync([asyncValidator("expected", {"one": true})]); var c = Validators.composeAsync([asyncValidator("expected", {"one": true})]);
var value = null; var value: any /** TODO #9100 */ = null;
(<Promise<any>>c(new Control("expected"))).then(v => value = v); (<Promise<any>>c(new Control("expected"))).then(v => value = v);
tick(1); tick(1);
@ -158,7 +158,7 @@ export function main() {
it("should ignore nulls", fakeAsync(() => { it("should ignore nulls", fakeAsync(() => {
var c = Validators.composeAsync([asyncValidator("expected", {"one": true}), null]); var c = Validators.composeAsync([asyncValidator("expected", {"one": true}), null]);
var value = null; var value: any /** TODO #9100 */ = null;
(<Promise<any>>c(new Control("invalid"))).then(v => value = v); (<Promise<any>>c(new Control("invalid"))).then(v => value = v);
tick(1); tick(1);