diff --git a/test/tsc-build/strict-checks/enableKeepAlive-and-keepAliveInitialDelay.ts b/test/tsc-build/strict-checks/enableKeepAlive-and-keepAliveInitialDelay.ts new file mode 100644 index 0000000000..00dfe8840d --- /dev/null +++ b/test/tsc-build/strict-checks/enableKeepAlive-and-keepAliveInitialDelay.ts @@ -0,0 +1,35 @@ +import { mysql, mysqlp } from '../index.js'; + +// Callback +(() => { + const poolOptions: mysql.PoolOptions = { + enableKeepAlive: true, + keepAliveInitialDelay: 0, + } + + const connectionOptions: mysql.ConnectionOptions = { + enableKeepAlive: true, + keepAliveInitialDelay: 0, + } + + mysql.createConnection(connectionOptions); + mysql.createPool(poolOptions); + mysql.createPoolCluster().add(poolOptions); +})(); + +// Promise +(() => { + const poolOptions: mysqlp.PoolOptions = { + enableKeepAlive: true, + keepAliveInitialDelay: 0, + } + + const connectionOptions: mysqlp.ConnectionOptions = { + enableKeepAlive: true, + keepAliveInitialDelay: 0, + } + + mysqlp.createConnection(connectionOptions); + mysqlp.createPool(poolOptions); + mysqlp.createPoolCluster().add(poolOptions); +})(); diff --git a/typings/mysql/lib/Connection.d.ts b/typings/mysql/lib/Connection.d.ts index 94527c5d9a..f6691f6485 100644 --- a/typings/mysql/lib/Connection.d.ts +++ b/typings/mysql/lib/Connection.d.ts @@ -258,6 +258,16 @@ export interface ConnectionOptions { */ rowsAsArray?: boolean; + /** + * Enable keep-alive on the socket. (Default: true) + */ + enableKeepAlive?: boolean; + + /** + * If keep-alive is enabled users can supply an initial delay. (Default: 0) + */ + keepAliveInitialDelay?: number; + charsetNumber?: number; compress?: boolean; @@ -312,10 +322,14 @@ declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) { | RowDataPacket[] | OkPacket | OkPacket[] - | ResultSetHeader + | ResultSetHeader, >( sql: string, - callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any + callback?: ( + err: QueryError | null, + result: T, + fields: FieldPacket[], + ) => any, ): Query; static createQuery< T extends @@ -323,11 +337,15 @@ declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) { | RowDataPacket[] | OkPacket | OkPacket[] - | ResultSetHeader + | ResultSetHeader, >( sql: string, values: any | any[] | { [param: string]: any }, - callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any + callback?: ( + err: QueryError | null, + result: T, + fields: FieldPacket[], + ) => any, ): Query; beginTransaction(callback: (err: QueryError | null) => void): void; @@ -338,7 +356,7 @@ declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) { changeUser( options: ConnectionOptions, - callback?: (err: QueryError | null) => void + callback?: (err: QueryError | null) => void, ): void; end(callback?: (err: QueryError | null) => void): void; @@ -363,7 +381,7 @@ declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) { prepare( sql: string, - callback?: (err: QueryError | null, statement: PrepareStatementInfo) => any + callback?: (err: QueryError | null, statement: PrepareStatementInfo) => any, ): Prepare; unprepare(sql: string): PrepareStatementInfo; diff --git a/typings/mysql/lib/Pool.d.ts b/typings/mysql/lib/Pool.d.ts index 93f8499561..90ed5e9bad 100644 --- a/typings/mysql/lib/Pool.d.ts +++ b/typings/mysql/lib/Pool.d.ts @@ -37,16 +37,6 @@ export interface PoolOptions extends ConnectionOptions { * is no limit to the number of queued connection requests. (Default: 0) */ queueLimit?: number; - - /** - * Enable keep-alive on the socket. (Default: true) - */ - enableKeepAlive?: boolean; - - /** - * If keep-alive is enabled users can supply an initial delay. (Default: 0) - */ - keepAliveInitialDelay?: number; } declare class Pool extends QueryableBase(ExecutableBase(EventEmitter)) {