cleanup(forms): added missing type annotations

Closes #1054
This commit is contained in:
vsavkin 2015-03-26 19:50:13 -07:00
parent c8385ad998
commit 6b985d56a5
1 changed files with 28 additions and 28 deletions

View File

@ -1,5 +1,5 @@
import {isPresent} from 'angular2/src/facade/lang';
import {Observable, ObservableWrapper} from 'angular2/src/facade/async';
import {Observable, ObservableController, ObservableWrapper} from 'angular2/src/facade/async';
import {StringMap, StringMapWrapper, ListWrapper, List} from 'angular2/src/facade/collection';
import {Validators} from './validators';
@ -21,40 +21,40 @@ export const INVALID = "INVALID";
export class AbstractControl {
_value:any;
_status:string;
_errors;
_errors:StringMap;
_pristine:boolean;
_parent:any; /* ControlGroup | ControlArray */
validator:Function;
valueChanges:Observable;
_valueChangesController;
_valueChangesController:ObservableController;
constructor(validator:Function) {
this.validator = validator;
this._pristine = true;
}
get value() {
get value():any {
return this._value;
}
get status() {
get status():string {
return this._status;
}
get valid() {
get valid():boolean {
return this._status === VALID;
}
get errors() {
get errors():StringMap {
return this._errors;
}
get pristine() {
get pristine():boolean {
return this._pristine;
}
get dirty() {
get dirty():boolean {
return ! this.pristine;
}
@ -78,7 +78,7 @@ export class Control extends AbstractControl {
this.valueChanges = ObservableWrapper.createObservable(this._valueChangesController);
}
updateValue(value:any) {
updateValue(value:any):void {
this._setValueErrorsStatus(value);
this._pristine = false;
@ -95,13 +95,13 @@ export class Control extends AbstractControl {
}
export class ControlGroup extends AbstractControl {
controls;
optionals;
controls:StringMap;
_optionals:StringMap;
constructor(controls, optionals = null, validator:Function = Validators.group) {
constructor(controls:StringMap, optionals:StringMap = null, validator:Function = Validators.group) {
super(validator);
this.controls = controls;
this.optionals = isPresent(optionals) ? optionals : {};
this._optionals = isPresent(optionals) ? optionals : {};
this._valueChangesController = ObservableWrapper.createController();
this.valueChanges = ObservableWrapper.createObservable(this._valueChangesController);
@ -110,17 +110,17 @@ export class ControlGroup extends AbstractControl {
this._setValueErrorsStatus();
}
include(controlName:string) {
StringMapWrapper.set(this.optionals, controlName, true);
include(controlName:string):void {
StringMapWrapper.set(this._optionals, controlName, true);
this._updateValue();
}
exclude(controlName:string) {
StringMapWrapper.set(this.optionals, controlName, false);
exclude(controlName:string):void {
StringMapWrapper.set(this._optionals, controlName, false);
this._updateValue();
}
contains(controlName:string) {
contains(controlName:string):boolean {
var c = StringMapWrapper.contains(this.controls, controlName);
return c && this._included(controlName);
}
@ -153,7 +153,7 @@ export class ControlGroup extends AbstractControl {
});
}
_reduceChildren(initValue, fn:Function) {
_reduceChildren(initValue:any, fn:Function) {
var res = initValue;
StringMapWrapper.forEach(this.controls, (control, name) => {
if (this._included(name)) {
@ -164,15 +164,15 @@ export class ControlGroup extends AbstractControl {
}
_included(controlName:string):boolean {
var isOptional = StringMapWrapper.contains(this.optionals, controlName);
return !isOptional || StringMapWrapper.get(this.optionals, controlName);
var isOptional = StringMapWrapper.contains(this._optionals, controlName);
return !isOptional || StringMapWrapper.get(this._optionals, controlName);
}
}
export class ControlArray extends AbstractControl {
controls:List;
constructor(controls:List, validator:Function = Validators.array) {
constructor(controls:List<AbstractControl>, validator:Function = Validators.array) {
super(validator);
this.controls = controls;
@ -183,28 +183,28 @@ export class ControlArray extends AbstractControl {
this._setValueErrorsStatus();
}
at(index:number) {
at(index:number):AbstractControl {
return this.controls[index];
}
push(control) {
push(control:AbstractControl):void {
ListWrapper.push(this.controls, control);
control.setParent(this);
this._updateValue();
}
insert(index:number, control) {
insert(index:number, control:AbstractControl):void {
ListWrapper.insert(this.controls, index, control);
control.setParent(this);
this._updateValue();
}
removeAt(index:number) {
removeAt(index:number):void {
ListWrapper.removeAt(this.controls, index);
this._updateValue();
}
get length() {
get length():number {
return this.controls.length;
}