how to use expo-sqlite execute sql with typescript?

  1. SDK Version: ~40.0.0

Hi all,

I want to use expo-sqlite to transaction object to execute an sql statement.

However, I got a problem in define the return value of the error function.

Here is the example code:


    // sql statement (ok)

    // input arguments (ok)

    // resolve (ok)
    () => {

    // what to do when error happen (Wrong!!!)
    // I got an error!!! 
    // Here ask me to return a boolean value for the **error callback funtion**, but how??? true or false???
    (_, err) => {

From the type definition file, I know, I need to return a boolean value for the error callback function, but how? true or false???

Do you have some idea how to do it???

P.S: I also wrote this question in stackoverflow, in case you want some points. :smiley:

To be honest I have no idea why the reject callback function does need a boolean return value? Shoulnd’t this method be void?

Have you got any examples using typescript and async/await? Not sure if my solution is appropriate:

export const fetchTypeSaveSql = async <T>(sqlStatement: string, args: any[] | undefined): Promise<T[]> => {
    return new Promise((resolve) => {
        db.transaction(tx => {
                sqlStatement, args,
                (_, result) => {
                    resolve(Array.from(result.rows as any) as T[])
                (_, error): boolean => {
                    return false