I'm working on a react native project but this is more of a typescript question. I have the SQLite embedded db wired up and I want to retrieve the whole array of rows. The problem is that the object looks like this
So as you can see _array
is meant to be private and is not included in the type definition. The type definitions are like so
export interface SQLResultSet { insertId: number; rowsAffected: number; rows: SQLResultSetRowList;}export interface SQLResultSetRowList { length: number; item(index: number): any;}
I've come up with three solutions but I'm not totally happy with any of them.
- Casting
SQLResultSet.rows
asany
(worse option as I lose my type checking). - Using the
length
property to make calls toSQLResultSet.rows.item()
, iterating over all of them and building the array from there (also not ideal because it's extra code that feels messy). - Making my own interface extending
SQLResultSetRowList
to add the_array: any[]
field (what I'm currently doing and at least I don't lose my type checks with that).
But, ideally, I want to know if there is some typescript syntax for working with a function as it's defined in item(index: number): any;
where I can simply get that all as an array.