I have seen the following error while I worked with file uploading logic in an Angular:
Property ‘files’ does not exist on type ‘EventTarget’.ngtsc(2339)
How my code looked like in the HTML and the component:
<input class="file-upload" type="file" (change)="submitUpload($event.target.files);"/>
submitUpload(files: FileList) {...}
I have fixed this error by using the $any
function. It has disabled this error for this expression:
<input class="file-upload" type="file" (change)="submitUpload($any($event).target.files);" />
However, it’s better to define a type for an $event
argument.