You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bug is typescript-only. The getWorksheet method specifies Worksheet as its return type, but when passing a non-existing sheet name as parameter, it returns in reality undefined.
Lib version: 4.3.0
Why is it an issue
If the undefined possibility isn't specified, then it's easy for developers to forget to account for this possibility when parsing a file coming from a user.
Steps To Reproduce
constwb=newExcelJS.Workbook();constws=wb.getWorksheet('nonExisting');// type of ws : Worksheet// actual value of ws : undefinedconstrow=ws.getRow(1)// throws
The expected behaviour:
the return type should be Worksheet | undefined
Possible solution
// modify the return type in index.d.ts// line 1746getWorksheet(indexOrName: number |string): Worksheet|undefined;