Skip to content

Commit

Permalink
Merge pull request #2087 from wellwelwel/issue-2086
Browse files Browse the repository at this point in the history
fix: change from .ts files to .d.ts
  • Loading branch information
wellwelwel authored Jun 26, 2023
2 parents 2d91b01 + 98e6f3a commit 989ec2b
Show file tree
Hide file tree
Showing 18 changed files with 272 additions and 359 deletions.
2 changes: 1 addition & 1 deletion test/tsc-build/mysql/createPool/callbacks/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { access } from '../../baseConnection.js';

const pool = mysql.createPool(access);

pool.getConnection((err, conn) => {
pool.getConnection((_err, conn) => {
conn.connection;

try {
Expand Down
2 changes: 1 addition & 1 deletion test/tsc-build/mysql/createPool/callbacks/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { access, sql, sqlPS, values } from '../../baseConnection.js';

/** getConnection and query */
{
mysql.createPool(access).getConnection((err, connection) => {
mysql.createPool(access).getConnection((_err, connection) => {
/** Overload: execute(sql, () => {}}) */
connection.execute(sql, (err, result, fields) => {
console.log(err, result, fields);
Expand Down
2 changes: 1 addition & 1 deletion test/tsc-build/mysql/createPool/callbacks/getConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { access } from '../../baseConnection.js';

const pool = mysql.createPool(access);

pool.getConnection((err, conn) => {
pool.getConnection((_err, conn) => {
try {
// @ts-expect-error: The connection can't get another connection
conn.getConnection();
Expand Down
2 changes: 1 addition & 1 deletion test/tsc-build/mysql/createPool/callbacks/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { access, sql, sqlPS, values } from '../../baseConnection.js';

/** getConnection */
{
mysql.createPool(access).getConnection((err, connection) => {
mysql.createPool(access).getConnection((_err, connection) => {
/** Overload: query(sql, () => {}}) */
connection.query(sql, (err, result, fields) => {
console.log(err, result, fields);
Expand Down
2 changes: 1 addition & 1 deletion test/tsc-build/mysql/createPool/callbacks/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { access } from '../../baseConnection.js';

const pool = mysql.createPool(access);

pool.getConnection((err, conn) => {
pool.getConnection((_err, conn) => {
conn.release();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { access } from '../../baseConnection.js';

const pool = mysql.createPool(access);

pool.getConnection((err, conn) => {
pool.getConnection((_err, conn) => {
pool.releaseConnection(conn);
});
4 changes: 2 additions & 2 deletions test/tsc-build/mysql/createPoolCluster/getConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ poolCluster.add('cluster1', uriAccess);
poolCluster.add('cluster2', access);

/** execute */
poolCluster.getConnection((err, conn) => {
poolCluster.getConnection((_err, conn) => {
/** Overload: execute(sql, () => {}}) */
conn.execute(sql, (err, result, fields) => {
console.log(err, result, fields);
Expand Down Expand Up @@ -38,7 +38,7 @@ poolCluster.getConnection((err, conn) => {
});

/** query */
poolCluster.getConnection('cluster1', (err, conn) => {
poolCluster.getConnection('cluster1', (_err, conn) => {
/** Overload: query(sql, () => {}}) */
conn.query(sql, (err, result, fields) => {
console.log(err, result, fields);
Expand Down
4 changes: 2 additions & 2 deletions test/tsc-build/mysql/createPoolCluster/of/getConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ poolCluster.add('cluster1', uriAccess);
poolCluster.add('cluster2', access);

/** execute */
poolCluster.of('cluster1').getConnection((err, conn) => {
poolCluster.of('cluster1').getConnection((_err, conn) => {
/** Overload: execute(sql, () => {}}) */
conn.execute(sql, (err, result, fields) => {
console.log(err, result, fields);
Expand Down Expand Up @@ -38,7 +38,7 @@ poolCluster.of('cluster1').getConnection((err, conn) => {
});

/** query */
poolCluster.of('cluster2').getConnection((err, conn) => {
poolCluster.of('cluster2').getConnection((_err, conn) => {
/** Overload: query(sql, () => {}}) */
conn.query(sql, (err, result, fields) => {
console.log(err, result, fields);
Expand Down
5 changes: 3 additions & 2 deletions test/tsc-build/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"target": "ES2016",
"module": "CommonJS",
"moduleResolution": "Node",
"isolatedModules": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
Expand All @@ -13,6 +12,8 @@
"strictFunctionTypes": false,
"skipLibCheck": false,
"noEmitOnError": true,
"noEmit": true
"noEmit": true,
"noUnusedParameters": true,
"isolatedModules": true,
}
}
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"strict": true,
"noImplicitAny": true,
"moduleResolution": "node",
"removeComments": false
"removeComments": false,
"noUnusedParameters": true,
"isolatedModules": true,
}
}
72 changes: 72 additions & 0 deletions typings/mysql/lib/protocol/sequences/ExecutableBase.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import {
OkPacket,
FieldPacket,
RowDataPacket,
ResultSetHeader,
} from '../packets/index.js';
import {
Query,
QueryError,
QueryOptions,
QueryableConstructor,
} from './Query.js';
export declare function ExecutableBase<T extends QueryableConstructor>(
Base?: T
): {
new (...args: any[]): {
execute<
T extends
| OkPacket
| ResultSetHeader
| RowDataPacket[]
| RowDataPacket[][]
| OkPacket[]
>(
sql: string,
callback?:
| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined
): Query;
execute<
T_1 extends
| OkPacket
| ResultSetHeader
| RowDataPacket[]
| RowDataPacket[][]
| OkPacket[]
>(
sql: string,
values: any,
callback?:
| ((err: QueryError | null, result: T_1, fields: FieldPacket[]) => any)
| undefined
): Query;
execute<
T_2 extends
| OkPacket
| ResultSetHeader
| RowDataPacket[]
| RowDataPacket[][]
| OkPacket[]
>(
options: QueryOptions,
callback?:
| ((err: QueryError | null, result: T_2, fields?: FieldPacket[]) => any)
| undefined
): Query;
execute<
T_3 extends
| OkPacket
| ResultSetHeader
| RowDataPacket[]
| RowDataPacket[][]
| OkPacket[]
>(
options: QueryOptions,
values: any,
callback?:
| ((err: QueryError | null, result: T_3, fields: FieldPacket[]) => any)
| undefined
): Query;
};
} & T;
104 changes: 0 additions & 104 deletions typings/mysql/lib/protocol/sequences/ExecutableBase.ts

This file was deleted.

72 changes: 72 additions & 0 deletions typings/mysql/lib/protocol/sequences/QueryableBase.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import {
OkPacket,
FieldPacket,
RowDataPacket,
ResultSetHeader,
} from '../packets/index.js';
import {
Query,
QueryError,
QueryOptions,
QueryableConstructor,
} from './Query.js';
export declare function QueryableBase<T extends QueryableConstructor>(
Base?: T
): {
new (...args: any[]): {
query<
T extends
| OkPacket
| ResultSetHeader
| RowDataPacket[]
| RowDataPacket[][]
| OkPacket[]
>(
sql: string,
callback?:
| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined
): Query;
query<
T_1 extends
| OkPacket
| ResultSetHeader
| RowDataPacket[]
| RowDataPacket[][]
| OkPacket[]
>(
sql: string,
values: any,
callback?:
| ((err: QueryError | null, result: T_1, fields: FieldPacket[]) => any)
| undefined
): Query;
query<
T_2 extends
| OkPacket
| ResultSetHeader
| RowDataPacket[]
| RowDataPacket[][]
| OkPacket[]
>(
options: QueryOptions,
callback?:
| ((err: QueryError | null, result: T_2, fields?: FieldPacket[]) => any)
| undefined
): Query;
query<
T_3 extends
| OkPacket
| ResultSetHeader
| RowDataPacket[]
| RowDataPacket[][]
| OkPacket[]
>(
options: QueryOptions,
values: any,
callback?:
| ((err: QueryError | null, result: T_3, fields: FieldPacket[]) => any)
| undefined
): Query;
};
} & T;
Loading

0 comments on commit 989ec2b

Please sign in to comment.