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
import*asmysqlfrom'mysql2/promise';letconnection=mysql.createConnection(process.env['DB']);connection.connect().then(()=>connection.query<mysql.RowDataPacket[]>('SELECT 1 + 1 AS solution')).then(([rows,fields])=>{console.log('The solution is: ',rows[0]['solution']);});
Is causing he following error in runtime:
TypeError: connection.connect is not a function
Please, do notice the error occurs just in runtime. The TypeScript compiler doesn't shows any errors.
Using TypeScript version 2.3.2, Node.js version v6.10.3 and mysql2 version 1.2.0 (tried to downgrade to 1.1.1 but the problem remains).
The text was updated successfully, but these errors were encountered:
Hmm, don't know why. Seems like it's not related to promises, but the connect function was removed? I don't remember where I copied this example from, maybe the library changed. Feel free to do a PR to correct this.
This code (from promises sample)
Is causing he following error in runtime:
Please, do notice the error occurs just in runtime. The TypeScript compiler doesn't shows any errors.
Using
TypeScript
version2.3.2
,Node.js
versionv6.10.3
andmysql2
version1.2.0
(tried to downgrade to1.1.1
but the problem remains).The text was updated successfully, but these errors were encountered: