Need help with implementing typescript strictNullChecks in an Angular 5 project.
The form structure is as follows:
this.signinForm = this.fb.group({
emailAddress: ['', NGValidators.isEmail()],
password: ['', Validators.required],
rememberMe: false,
});
To access the rememberMe
control, I use
this.signinForm.get('rememberMe')
. However, since the return type of FormGroup#get
method is AbstractControl | null
, TypeScript throws an error for this.signinForm.get('rememberMe').value
(as it might be null).
Is there a way to specify to TypeScript that, in this particular scenario, the return value of
this.signinForm.get('rememberMe')
will always be AbstractControl
and not AbstractControl | null
?