TS2531: Object is possibly 'null' : <p>I have the following function:-</p>

<pre><code>uploadPhoto() {
    var nativeElement: HTMLInputElement = this.fileInput.nativeElement;

    this.photoService.upload(this.vehicleId, nativeElement.files[0])
        .subscribe(x =&gt; console.log(x));
}
</code></pre>

<p>however on the nativeElement.files[0], I am getting a typescript error, "Object is possibly 'null'".  Anyone can help me solve this issue?  </p>

<p>I tried to declare the nativeElement as a null value, however did not manage to succeed.</p>

<p>Thanks for your help and time.</p>
