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

@ -16,7 +16,7 @@ import {FormArray} from '../src/model';
export function main() {
function asyncValidator(expected: string, timeouts = {}) {
return (c: FormControl) => {
let resolve: (result: any) => void = undefined !;
let resolve: (result: any) => void;
const promise = new Promise(res => { resolve = res; });
const t = (timeouts as any)[c.value] != null ? (timeouts as any)[c.value] : 0;
const res = c.value != expected ? {'async': true} : null;
@ -49,7 +49,7 @@ export function main() {
describe('boxed values', () => {
it('should support valid boxed values on creation', () => {
const c = new FormControl({value: 'some val', disabled: true}, null !, null !);
const c = new FormControl({value: 'some val', disabled: true}, null, null);
expect(c.disabled).toBe(true);
expect(c.value).toBe('some val');
expect(c.status).toBe('DISABLED');
@ -63,13 +63,13 @@ export function main() {
});
it('should not treat objects as boxed values if they have more than two props', () => {
const c = new FormControl({value: '', disabled: true, test: 'test'}, null !, null !);
const c = new FormControl({value: '', disabled: true, test: 'test'}, null, null);
expect(c.value).toEqual({value: '', disabled: true, test: 'test'});
expect(c.disabled).toBe(false);
});
it('should not treat objects as boxed values if disabled is missing', () => {
const c = new FormControl({value: '', test: 'test'}, null !, null !);
const c = new FormControl({value: '', test: 'test'}, null, null);
expect(c.value).toEqual({value: '', test: 'test'});
expect(c.disabled).toBe(false);
});
@ -156,7 +156,7 @@ export function main() {
describe('asyncValidator', () => {
it('should run validator with the initial value', fakeAsync(() => {
const c = new FormControl('value', null !, asyncValidator('expected'));
const c = new FormControl('value', null, asyncValidator('expected'));
tick();
expect(c.valid).toEqual(false);
@ -164,7 +164,7 @@ export function main() {
}));
it('should support validators returning observables', fakeAsync(() => {
const c = new FormControl('value', null !, asyncValidatorReturningObservable);
const c = new FormControl('value', null, asyncValidatorReturningObservable);
tick();
expect(c.valid).toEqual(false);
@ -172,7 +172,7 @@ export function main() {
}));
it('should rerun the validator when the value changes', fakeAsync(() => {
const c = new FormControl('value', null !, asyncValidator('expected'));
const c = new FormControl('value', null, asyncValidator('expected'));
c.setValue('expected');
tick();
@ -193,7 +193,7 @@ export function main() {
}));
it('should mark the control as pending while running the async validation', fakeAsync(() => {
const c = new FormControl('', null !, asyncValidator('expected'));
const c = new FormControl('', null, asyncValidator('expected'));
expect(c.pending).toEqual(true);
@ -204,7 +204,7 @@ export function main() {
it('should only use the latest async validation run', fakeAsync(() => {
const c = new FormControl(
'', null !, asyncValidator('expected', {'long': 200, 'expected': 100}));
'', null, asyncValidator('expected', {'long': 200, 'expected': 100}));
c.setValue('long');
c.setValue('expected');
@ -216,14 +216,14 @@ export function main() {
it('should support arrays of async validator functions if passed', fakeAsync(() => {
const c =
new FormControl('value', null !, [asyncValidator('expected'), otherAsyncValidator]);
new FormControl('value', null, [asyncValidator('expected'), otherAsyncValidator]);
tick();
expect(c.errors).toEqual({'async': true, 'other': true});
}));
it('should add single async validator', fakeAsync(() => {
const c = new FormControl('value', null !);
const c = new FormControl('value', null);
c.setAsyncValidators(asyncValidator('expected'));
expect(c.asyncValidator).not.toEqual(null);
@ -235,7 +235,7 @@ export function main() {
}));
it('should add async validator from array', fakeAsync(() => {
const c = new FormControl('value', null !);
const c = new FormControl('value', null);
c.setAsyncValidators([asyncValidator('expected')]);
expect(c.asyncValidator).not.toEqual(null);
@ -634,7 +634,8 @@ export function main() {
tick();
expect(log).toEqual([
'value: \'\'',
'' +
'value: \'\'',
'status: \'INVALID\'',
'value: \'nonEmpty\'',
'status: \'PENDING\'',
@ -934,7 +935,7 @@ export function main() {
});
it('should clear out async errors when disabled', fakeAsync(() => {
const c = new FormControl('', null !, asyncValidator('expected'));
const c = new FormControl('', null, asyncValidator('expected'));
tick();
expect(c.errors).toEqual({'async': true});