Skip to content

Commit 89923c7

Browse files
author
Michael Kornelakis
committed
type improvemnts and readme update
1 parent 257f1cb commit 89923c7

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ In the `typescript` folder there are the equivalent examples. In order to run th
1414

1515
### Note
1616

17-
I am using `ts-node` in order to avoid including a bundler. If you try to compile the typescript files to javascript using ithe `outDir` option in `tsconfig` then you will get import errors beacuse we are pulling the `index` file form the root of the project.
17+
These examples are using `ts-node` in order to avoid including a bundler. If you try to compile the typescript files to javascript using ithe `outDir` option in `tsconfig` then you will get import errors beacuse we are pulling the `index` file form the root of the project.

examples/connection/typescript/returnArgumentsArray.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { FieldInfo, Query } from 'mysql';
21
import mysql from '../../../index';
32
import { Employee } from './employee';
43

@@ -13,7 +12,7 @@ function run() {
1312
}).then((conn) => {
1413
connection = conn;
1514

16-
return connection.query<[data: Employee[], fields: FieldInfo[], query: Query]>('select * from employees limit 0, 10');
15+
return connection.query<[data: Employee[], fields: mysql.FieldInfo[], query: mysql.Query]>('select * from employees limit 0, 10');
1716
}).then(([data, fields, query]) => {
1817
console.log(`The SQL for the query was: ${query.sql}\n`);
1918

@@ -40,7 +39,7 @@ async function runAwait() {
4039
returnArgumentsArray: true
4140
});
4241

43-
const [data, fields, query] = await connection.query<[data: Employee[], fields: FieldInfo[], query: Query]>('select * from employees limit 0, 10');
42+
const [data, fields, query] = await connection.query<[data: Employee[], fields: mysql.FieldInfo[], query: mysql.Query]>('select * from employees limit 0, 10');
4443

4544
console.log(`The SQL for the query was: ${query.sql}\n`);
4645

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export function createPoolCluster(config: mysql.PoolClusterConfig): Bluebird<Poo
1010
export { Types, escape, escapeId, format, raw, ConnectionOptions, PoolClusterConfig, MysqlError } from 'mysql';
1111

1212
export type mysqlModule = typeof mysql;
13+
export type FieldInfo = typeof mysql.FieldInfo;
14+
export type Query = typeof mysql.Query;
1315

1416
export interface ConnectionConfig extends mysql.ConnectionConfig {
1517
mysqlWrapper?: (mysql: mysqlModule, callback?: (err: Error | null, success?: mysqlModule) => void) => mysqlModule | Promise<mysqlModule> | void;

0 commit comments

Comments
 (0)