Revert "fix(forms): Update types for TypeScript nullability support"

This reverts commit 6649743a2d.

Broke in G3.
This commit is contained in:
Tobias Bosch
2017-04-17 09:47:43 -07:00
parent 2ddf3bcdd1
commit 6d930d2fc5
27 changed files with 330 additions and 343 deletions

View File

@ -143,11 +143,9 @@ export class Validators {
* Compose multiple validators into a single function that returns the union
* of the individual error maps.
*/
static compose(validators: null): null;
static compose(validators: (ValidatorFn|null|undefined)[]): ValidatorFn|null;
static compose(validators: (ValidatorFn|null|undefined)[]|null): ValidatorFn|null {
static compose(validators: ValidatorFn[]): ValidatorFn {
if (!validators) return null;
const presentValidators: ValidatorFn[] = validators.filter(isPresent) as any;
const presentValidators = validators.filter(isPresent);
if (presentValidators.length == 0) return null;
return function(control: AbstractControl) {
@ -155,9 +153,9 @@ export class Validators {
};
}
static composeAsync(validators: (AsyncValidatorFn|null)[]): AsyncValidatorFn|null {
static composeAsync(validators: AsyncValidatorFn[]): AsyncValidatorFn {
if (!validators) return null;
const presentValidators: AsyncValidatorFn[] = validators.filter(isPresent) as any;
const presentValidators = validators.filter(isPresent);
if (presentValidators.length == 0) return null;
return function(control: AbstractControl) {
@ -190,7 +188,7 @@ function _executeAsyncValidators(control: AbstractControl, validators: AsyncVali
function _mergeErrors(arrayOfErrors: ValidationErrors[]): ValidationErrors|null {
const res: {[key: string]: any} =
arrayOfErrors.reduce((res: ValidationErrors | null, errors: ValidationErrors | null) => {
return errors != null ? {...res !, ...errors} : res !;
return errors != null ? {...res, ...errors} : res;
}, {});
return Object.keys(res).length === 0 ? null : res;
}