TypeScript strictNullChecks - Object is possibly 'null'

angular, typescript2.0

Solution

Try using Non-null assertion operator like

this.form.get('username')!.value; // notice !

Problem

After enabling `strictNullChecks` with Angular 4.1.1, getting several errors for `null` checks. I have fixed bundles of them but unable to fix the same `Object is possibly 'null'` for `this.form.get('username').value`. Likewise others, I have tried the same but unable to fix the error. ``` if (this.form.get('username') != null) { body.append('username', this.form.get('username').value); } ```

Original source