fix(typings): repair broken type-checking for StringMap

Note that the previous type of StringMap was overly permissive and didn't catch errors.
Also we have to explicitly type empty objects, which is explained here:
https://github.com/Microsoft/TypeScript/issues/5089

Closes #4487
This commit is contained in:
Alex Eagle
2015-10-02 17:33:21 -07:00
committed by Alex Eagle
parent 7c4199cd1c
commit 208f3d4c65
16 changed files with 36 additions and 36 deletions

View File

@ -97,7 +97,7 @@ export class FormBuilder {
}
_reduceControls(controlsConfig: any): {[key: string]: modelModule.AbstractControl} {
var controls = {};
var controls: {[key: string]: modelModule.AbstractControl} = {};
StringMapWrapper.forEach(controlsConfig, (controlConfig, controlName) => {
controls[controlName] = this._createControl(controlConfig);
});

View File

@ -29,14 +29,14 @@ export class Validators {
return function(control: modelModule.Control) {
var res = ListWrapper.reduce(validators, (res, validator) => {
var errors = validator(control);
return isPresent(errors) ? StringMapWrapper.merge(res, errors) : res;
return isPresent(errors) ? StringMapWrapper.merge(<any>res, <any>errors) : res;
}, {});
return StringMapWrapper.isEmpty(res) ? null : res;
};
}
static group(group: modelModule.ControlGroup): {[key: string]: boolean} {
var res = {};
static group(group: modelModule.ControlGroup): {[key: string]: any[]} {
var res: {[key: string]: any[]} = {};
StringMapWrapper.forEach(group.controls, (control, name) => {
if (group.contains(name) && isPresent(control.errors)) {
Validators._mergeErrors(control, res);
@ -45,8 +45,8 @@ export class Validators {
return StringMapWrapper.isEmpty(res) ? null : res;
}
static array(array: modelModule.ControlArray): {[key: string]: boolean} {
var res = {};
static array(array: modelModule.ControlArray): {[key: string]: any[]} {
var res: {[key: string]: any[]} = {};
array.controls.forEach((control) => {
if (isPresent(control.errors)) {
Validators._mergeErrors(control, res);