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
{{ message }}
Repository navigation
Cannot properly type results for query with rowsAsArray option set to true #55
I don't know what I'm doing wrong. I cannot properly type results when the option rowsAsArray is enabled.
My SQL returns an array of arrays that contains only one string eg:
// connection.promise().query("SHOW TABLES LIKE 'table_%';");[['table_1'],['table_2'],['table_3'],['table_4'],]
I want to flat this result in my helper function but TS complaints about types mismatch.
See example below
constlistTablesSql="SHOW TABLES LIKE 'table_%';"asyncstrictTypeInQuery(): Promise<string[]>{// error: `Type 'string' is not assignable to type 'RowDataPacket'`const[rows]=awaitconnection.promise().query<string[]>({sql: listTablesSql,rowsAsArray: true});returnrows.flat(1);}asyncinferType(): Promise<string[]>{// error: `Type 'string' is not assignable to type 'RowDataPacket'`const[rows]=awaitconnection.promise().query({sql: listTablesSql,rowsAsArray: true});returnrows.flat(1);// TS:error `Type 'RowDataPacket' is not assignable to type 'string'.`}
Activity