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:
@ -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);
|
||||
});
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user