sidorares / node-mysql2

:zap: fast mysqljs/mysql compatible mysql driver for node.js
https://sidorares.github.io/node-mysql2/
MIT License
4.03k stars 611 forks source link

Type 'Query' must have a '[Symbol.iterator]()' method that returns an iterator.ts(2488) Exception #2571

Closed gordonwho closed 5 months ago

gordonwho commented 5 months ago

All, I am getting the following error :

Type 'Query' must have a '[Symbol.iterator]()' method that returns an iterator.ts(2488)

from the following code:

const connection = await getConnection();
let [columns] = await connection.query(`desc ${data.tableName}`);

Below is the code for getconnection

async function getConnection() {
  // const config = await getConnectionConfig(process.env.DB_SECRET || 'database/wmsRW');
  const config = await getConnectionConfig(process.env.DB_SECRET || 'database/wmsRW');
  try {
    const connection = await mysql.createConnection({
      host: config.host,
      password: config.password,
      user: config.username,
      database: config.dbname
    });
    return connection;
  } catch (e) {
    console.log(e);
    throw e;
  }
}

Below are my settings: TyepScript: 5.3.3 NodeJs: 18.18

In package.json:

Dependencies
{
   "mysql2" : "3.9.3"
}
DevDepdendencies
{
 "@types/mysql": "2.15.5",
}

In my tsconfig I have:

{
  "extends": "@tsconfig/node18/tsconfig.json",
 "compilerOptions": {
        "lib": ["ES2022", "es2018", "es5", "es6", "dom", "dom.iterable"],
}
}

Any idea on how to fix the issue? Gordon

gordonwho commented 5 months ago

It's a express-serve-static-core package issue see here: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/43434