Refactoring an Excel Import Functions so as to not use global variables

I am attempting to import an excel file into a project using the xlsx library. I have the following function below

public async ParseExcelFile(excelFile)
{
//Set up empty Excel Array
let excelContents : Array<any> = [];
let error : any = null;
return new Promise<Object>((resolve, reject) =>
  {
    const inputFile: DataTransfer = <DataTransfer>(excelFile.target); 
    const fileReader: FileReader = new FileReader();
    fileReader.onload = (event: any) => 
    {
      const binaryString: string = event.target.result;
      const workBook: XLSX.WorkBook = XLSX.read(binaryString, { type: 'binary', sheetStubs: true}); 
      /* sheetstubs true supposedly shows empty cells but isn't */

      const workSheetName: string = workBook.SheetNames[0];
      const workSheet: XLSX.WorkSheet = workBook.Sheets[workSheetName];

      this.data = <aoa>(XLSX.utils.sheet_to_json(workSheet, 
      {header: 1, blankrows: true })); 
    };
    fileReader.readAsBinaryString(inputFile.files[0]); 

    {
      // parse the excel data into the item format
      let item : {level:number,ipn:string,quantity:number,refdes:string,revision:string,description:string,mfg:string,mpn:string,uom:string,isAlternate:boolean};

    // push the item into the excel list
    excelContents.push(item);
    }

  // if all ok? return the excel file contents
  if(error)reject(error);
  else resolve(excelContents);
  });

however, when I upload the excel file I am met with the following error:

[Error] ERROR – Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'excelFile.target')

ZoneAwarePromise

step

ZoneAwarePromise


callWithDebugContext
dispatchEvent

onInvokeTask


invokeTask
globalZoneAwareCallback
Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'excelFile.target')

ZoneAwarePromise

step

ZoneAwarePromise


callWithDebugContext
dispatchEvent

onInvokeTask


invokeTask
globalZoneAwareCallbackresolvePromiseresolvePromise(anonymous function)step(anonymous function)ZoneAwarePromise(anonymous function)(anonymous function)callWithDebugContextdispatchEvent(anonymous function)onInvokeTask(anonymous function)(anonymous function)invokeTaskglobalZoneAwareCallback
    defaultErrorLogger (core.umd.js:2639)
    (anonymous function) (core.umd.js:2655)
    next (core.umd.js:18520:144)
    (anonymous function) (core.umd.js:16378)
    (anonymous function) (Subscriber.js:205)
    (anonymous function) (Subscriber.js:143)
    (anonymous function) (Subscriber.js:89)
    (anonymous function) (Subscriber.js:66)
    (anonymous function) (Subject.js:60)
    (anonymous function) (core.umd.js:16369:85)
    (anonymous function) (zone.js:138)
    onHandleError (core.umd.js:18173)
    (anonymous function) (zone.js:152)
    _loop_1 (zone.js:697)
    (anonymous function) (zone.js:706)
    drainMicroTaskQueue (zone.js:596)
    (anonymous function) (zone.js:490)
    invokeTask (zone.js:1650)
    globalZoneAwareCallback (zone.js:1676)

however, I am confused as to what this error is trying to tell me, and what might be a possible solution to fixing it.

Source: New feed
Source Url Refactoring an Excel Import Functions so as to not use global variables