fix(forms): Update types for TypeScript nullability support

This reverts commit 6d930d2fc5.
This commit is contained in:
Miško Hevery
2017-04-17 11:13:30 -07:00
committed by Tobias Bosch
parent bc431888f3
commit 57bc245cb4
27 changed files with 343 additions and 330 deletions

View File

@ -18,45 +18,49 @@ import {ValidationErrors} from './validators';
* @stable
*/
export abstract class AbstractControlDirective {
get control(): AbstractControl { throw new Error('unimplemented'); }
abstract get control(): AbstractControl|null;
get value(): any { return this.control ? this.control.value : null; }
get valid(): boolean { return this.control ? this.control.valid : null; }
get valid(): boolean|null { return this.control ? this.control.valid : null; }
get invalid(): boolean { return this.control ? this.control.invalid : null; }
get invalid(): boolean|null { return this.control ? this.control.invalid : null; }
get pending(): boolean { return this.control ? this.control.pending : null; }
get pending(): boolean|null { return this.control ? this.control.pending : null; }
get errors(): ValidationErrors|null { return this.control ? this.control.errors : null; }
get pristine(): boolean { return this.control ? this.control.pristine : null; }
get pristine(): boolean|null { return this.control ? this.control.pristine : null; }
get dirty(): boolean { return this.control ? this.control.dirty : null; }
get dirty(): boolean|null { return this.control ? this.control.dirty : null; }
get touched(): boolean { return this.control ? this.control.touched : null; }
get touched(): boolean|null { return this.control ? this.control.touched : null; }
get untouched(): boolean { return this.control ? this.control.untouched : null; }
get untouched(): boolean|null { return this.control ? this.control.untouched : null; }
get disabled(): boolean { return this.control ? this.control.disabled : null; }
get disabled(): boolean|null { return this.control ? this.control.disabled : null; }
get enabled(): boolean { return this.control ? this.control.enabled : null; }
get enabled(): boolean|null { return this.control ? this.control.enabled : null; }
get statusChanges(): Observable<any> { return this.control ? this.control.statusChanges : null; }
get statusChanges(): Observable<any>|null {
return this.control ? this.control.statusChanges : null;
}
get valueChanges(): Observable<any> { return this.control ? this.control.valueChanges : null; }
get valueChanges(): Observable<any>|null {
return this.control ? this.control.valueChanges : null;
}
get path(): string[] { return null; }
get path(): string[]|null { return null; }
reset(value: any = undefined): void {
if (this.control) this.control.reset(value);
}
hasError(errorCode: string, path: string[] = null): boolean {
hasError(errorCode: string, path?: string[]): boolean {
return this.control ? this.control.hasError(errorCode, path) : false;
}
getError(errorCode: string, path: string[] = null): any {
getError(errorCode: string, path?: string[]): any {
return this.control ? this.control.getError(errorCode, path) : null;
}
}