I'm using the following code for reading in contents of a locally stored file.
onFile(event: any) {
console.log(event);
const file = event.target.files[0];
const reader = new FileReader();
reader.onloadend = (ev: any) => { console.log(ev); };
reader.readAsText(file);
}
Investigating the two console outputs, I see that the two types printed out are Event and ProgressEvent. So I've refactored my methods to correspond the types of the parameters like so.
onFile(event: Event) {
console.log(event);
const file = event.target.files[0];
const reader = new FileReader();
reader.onloadend = (ev: ProgressEvent) => { console.log(ev, $event.target.result); };
reader.readAsText(file);
}
However, although I've done that, I still see TsLint nag about files[0] and result not present in their types. Have I specified incorrect type for the operations? What is the appropriate type in such case?