From ff3c36ca8b092f8ab16fc81400f6c63524cd971d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Weslley=20Ara=C3=BAjo?= <46850407+wellwelwel@users.noreply.github.com> Date: Mon, 12 Jun 2023 19:49:24 -0300 Subject: [PATCH] fix: `createPool` `promise` as `PromisePool` (#2060) --- .../mysql/createPool/promise/promise.ts | 16 ++++++++++++++++ typings/mysql/lib/Pool.d.ts | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 test/tsc-build/mysql/createPool/promise/promise.ts diff --git a/test/tsc-build/mysql/createPool/promise/promise.ts b/test/tsc-build/mysql/createPool/promise/promise.ts new file mode 100644 index 0000000000..780254b2d6 --- /dev/null +++ b/test/tsc-build/mysql/createPool/promise/promise.ts @@ -0,0 +1,16 @@ +import { mysql, mysqlp } from '../../../index'; +import { access } from '../../baseConnection'; + +(async () => { + let pool: mysql.Pool | null = null; + let promisePool: mysqlp.Pool | null = null; + let conn: mysqlp.PoolConnection | null = null; + + if (pool === null) return; + + pool = mysql.createPool(access); + promisePool = pool.promise(); + conn = await promisePool.getConnection(); + + conn.release(); +})(); diff --git a/typings/mysql/lib/Pool.d.ts b/typings/mysql/lib/Pool.d.ts index 29c4891f9d..2881ec896d 100644 --- a/typings/mysql/lib/Pool.d.ts +++ b/typings/mysql/lib/Pool.d.ts @@ -4,7 +4,7 @@ import {OkPacket, RowDataPacket, FieldPacket, ResultSetHeader} from './protocol/ import Connection = require('./Connection'); import PoolConnection = require('./PoolConnection'); import {EventEmitter} from 'events'; -import {PoolConnection as PromisePoolConnection} from '../../../promise'; +import {Pool as PromisePool} from '../../../promise'; declare namespace Pool { @@ -78,7 +78,7 @@ declare class Pool extends EventEmitter { on(event: string, listener: Function): this; on(event: 'connection', listener: (connection: PoolConnection) => any): this; - promise(promiseImpl?: PromiseConstructor): PromisePoolConnection; + promise(promiseImpl?: PromiseConstructor): PromisePool; } export = Pool;