I am working with several document libraries, some of them with folders (unfortunately). I develop web apps using TypeScript with REST API server interaction.
I am finding that a view configured to show Totals (counts of items for a column) is NOT matching SharePoint's own export to Excel worksheet item data counts (rows), nor my script which distinguishes folder from file items.
To illustrate, the document library has the ID and Name column both with 498 file items (17 folder items, filtered out using Content Type system column). My web app will count 490 file items. When I export the item data to Excel file from the view menu, the worksheet has 490 items (rows).
That is, the list/lib view column Total value has 8 extra items it is counting. I am not sure how to track them down or if they even exist. This is not strictly my script: I am using a SharePoint list view menu feature (export to Excel) and this result and my script agree.