-
-
Notifications
You must be signed in to change notification settings - Fork 597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect typings lead to pool.destroy is not a function #2667
Labels
Comments
I'm guessing that this is probably what's going on with #2465 |
Thanks, @dancrumb 🙋🏻♂️ I'll keep some debugging to check later: import mysql from 'mysql2';
// import mysql from 'mysql2/promise';
const pool = mysql.createPool({});
typeof pool.addListener === 'undefined' && console.log('addListener');
typeof pool.beginTransaction === 'undefined' && console.log('beginTransaction');
typeof pool.changeUser === 'undefined' && console.log('changeUser');
typeof pool.commit === 'undefined' && console.log('commit');
typeof pool.config === 'undefined' && console.log('config');
typeof pool.connect === 'undefined' && console.log('connect');
typeof pool.destroy === 'undefined' && console.log('destroy');
typeof pool.emit === 'undefined' && console.log('emit');
typeof pool.end === 'undefined' && console.log('end');
typeof pool.escape === 'undefined' && console.log('escape');
typeof pool.escapeId === 'undefined' && console.log('escapeId');
typeof pool.eventNames === 'undefined' && console.log('eventNames');
typeof pool.execute === 'undefined' && console.log('execute');
typeof pool.format === 'undefined' && console.log('format');
typeof pool.getConnection === 'undefined' && console.log('getConnection');
typeof pool.getMaxListeners === 'undefined' && console.log('getMaxListeners');
typeof pool.listenerCount === 'undefined' && console.log('listenerCount');
typeof pool.listeners === 'undefined' && console.log('listeners');
typeof pool.off === 'undefined' && console.log('off');
typeof pool.on === 'undefined' && console.log('on');
typeof pool.once === 'undefined' && console.log('once');
typeof pool.pause === 'undefined' && console.log('pause');
typeof pool.ping === 'undefined' && console.log('ping');
typeof pool.pool === 'undefined' && console.log('pool');
typeof pool.prepare === 'undefined' && console.log('prepare');
typeof pool.prependListener === 'undefined' && console.log('prependListener');
typeof pool.prependOnceListener === 'undefined' && console.log('prependOnceListener');
typeof pool.query === 'undefined' && console.log('query');
typeof pool.rawListeners === 'undefined' && console.log('rawListeners');
typeof pool.releaseConnection === 'undefined' && console.log('releaseConnection');
typeof pool.removeAllListeners === 'undefined' && console.log('removeAllListeners');
typeof pool.removeListener === 'undefined' && console.log('removeListener');
typeof pool.resume === 'undefined' && console.log('resume');
typeof pool.rollback === 'undefined' && console.log('rollback');
typeof pool.setMaxListeners === 'undefined' && console.log('setMaxListeners');
typeof pool.threadId === 'undefined' && console.log('threadId');
typeof pool.unprepare === 'undefined' && console.log('unprepare');
typeof pool.promise === 'undefined' && console.log('promise');
All cited methods are based in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using version 3.9.7 of
mysql2
, running TypeScript 5.4.3I'm importing this module with
import mysql from "mysql2/promise";
When I create a
Pool
withmysql.createPool
, I get my pool and am able to use it without any problems.However, when I come to wrap things up, I call
pool.destroy()
. No complaints from TS, but when I run the code, I get:I took a look at
promises.d.ts
in the code base and I can see why there's no type error:Since
destroy
is a method in theConnection
interface, it's also a method in thePool
interface.I'm not sure if the bug is the assertion that
Pool
extendsConnection
or whether it's just thatPool
only supports some methods ofConnection
.The text was updated successfully, but these errors were encountered: