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
When using a Promise Pool, and subscribing to events (e.g.pool.on('acquire', (connection) => {})) the connection object does not match the type.
In the types, the connection type is exposed as a Promise PoolConnection, where in reality there is no conversion from the original, and so it's actually a base PoolConnection type. Meaning if I want to use it, i have to call the Promise() helper, which isn't on the Promise PoolConnection type.
This is causing a bit of confusion on my end, and i'm not sure what the expected behaviour is? Should these be converted to PromisePoolConnections, or should the types be updated appropriately?
import{PoolConnection}from'mysql2'importmysqlfrom'mysql2/promise'// this is a PromisePoolconstpool=mysql.createPool(options);// PoolConnection here is NOT a PoolConnection from the Promise lib// but typescript thinks it is, and so is giving an error.pool.on('acquire',async(connection: PoolConnection)=>{awaitconnection.promise().beginTransaction();});
The text was updated successfully, but these errors were encountered:
When using a Promise Pool, and subscribing to events (e.g.
pool.on('acquire', (connection) => {})
) the connection object does not match the type.In the types, the connection type is exposed as a Promise PoolConnection, where in reality there is no conversion from the original, and so it's actually a base PoolConnection type. Meaning if I want to use it, i have to call the
Promise()
helper, which isn't on the Promise PoolConnection type.This is causing a bit of confusion on my end, and i'm not sure what the expected behaviour is? Should these be converted to PromisePoolConnections, or should the types be updated appropriately?
The text was updated successfully, but these errors were encountered: