Skip to content

chore: update project #50

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
Typescript Typings for [mysql2](https://www.npmjs.com/package/mysql2).

## Installation

```sh
typings install --save mysql2
```
or
```sh
npm install --save-dev types/mysql2

# for specific version
npm install --save-dev types/mysql2#semver:version
```

Expand All @@ -32,7 +32,6 @@ connection.execute('UPDATE posts SET title = ? WHERE id = ?', ['Hello World', 1]

[More examples](./test)


## Contributing
You can run them the tests with `npm run build` and `npm run test`.

You can run them the tests with `yarn tsc`, `yarn lint` and `yarn test`.
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export interface ConnectionOptions extends mysql.ConnectionOptions {
export interface PoolOptions extends mysql.PoolOptions, ConnectionOptions {}

export interface FieldPacket extends mysql.FieldPacket {
columnType: number
columnLength: number
schema: string
characterSet: number
columnType: number;
columnLength: number;
schema: string;
characterSet: number;
}

type authPlugins =
Expand Down
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@
"name": "@types/mysql2",
"version": "1.0.0",
"description": "Typings for mysql2",
"license": "ISC",
"author": "Felix Becker <[email protected]>",
"scripts": {
"build": "typings bundle -o test/bundle.d.ts",
"test": "tsc -p test",
"lint": "tslint -c tslint.json \"lib/**/*.d.ts\" index.d.ts",
"test": "tsc -p test",
"typedoc": "typedoc --includeDeclarations --excludeExternals --name mysql --mode file --readme none --out typedoc lib index.d.ts typings/index.d.ts"
},
"author": "Felix Becker <[email protected]>",
"license": "ISC",
"types": "index.d.ts",
"dependencies": {
"@types/mysql": "types/mysql",
"@types/node": "*"
},
"devDependencies": {
"mysql2": "^1.0.0",
"tslint": "^5.0.0",
"mysql2": "^2.1.0",
"npm-check-updates": "^8.0.3",
"tslint": "^6.1.3",
"tslint-config-typings": "^0.3.1",
"typedoc": "^0.7.0",
"typescript": "^2.2.1",
"typings": "^2.0.0"
},
"dependencies": {
"@types/mysql": "types/mysql"
"typedoc": "^0.19.0",
"typescript": "^4.0.2"
}
}
14 changes: 7 additions & 7 deletions test/promise.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@

import * as mysql from 'mysql2/promise';
import * as promise from '../promise';

// Connections
async function testConnections() {
let connection = await mysql.createConnection({
let connection = await promise.createConnection({
host: 'localhost',
user: 'me',
password: 'secret'
});

connection.connect()
.then(() => connection.query<mysql.RowDataPacket[]>('SELECT 1 + 1 AS solution'))
.then(() => connection.query<promise.RowDataPacket[]>('SELECT 1 + 1 AS solution'))
.then(([rows, fields]) => {
console.log('The solution is: ', rows[0]['solution']);
});

connection.connect()
.then(() => connection.execute<mysql.RowDataPacket[]>('SELECT 1 + 1 AS solution'))
.then(() => connection.execute<promise.RowDataPacket[]>('SELECT 1 + 1 AS solution'))
.then(([rows, fields]) => {
console.log('The solution is: ', rows[0]['solution']);
});
Expand All @@ -31,14 +31,14 @@ let poolConfig = {
password: 'secret'
};

let pool = mysql.createPool(poolConfig);
let pool = promise.createPool(poolConfig);

pool.query<mysql.RowDataPacket[]>('SELECT 1 + 1 AS solution')
pool.query<promise.RowDataPacket[]>('SELECT 1 + 1 AS solution')
.then(([rows, fields]) => {
console.log('The solution is: ', rows[0]['solution']);
});

pool.execute<mysql.RowDataPacket[]>('SELECT 1 + 1 AS solution')
pool.execute<promise.RowDataPacket[]>('SELECT 1 + 1 AS solution')
.then(([rows, fields]) => {
console.log('The solution is: ', rows[0]['solution']);
});
Expand Down
2 changes: 1 addition & 1 deletion test/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import * as fs from 'fs';
import * as mysql from 'mysql2';
import * as stream from 'stream';
import * as mysql from '..';

// Connections
let connection = mysql.createConnection({
Expand Down
8 changes: 1 addition & 7 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@
"strictNullChecks": true,
"noEmit": true,
"module": "commonjs",
"typeRoots": [
"../typings/globals",
"../typings/modules"
]
},
"include": [
"./*.ts",
"./bundle.d.ts",
"../typings/index.d.ts"
"./*.ts"
]
}
10 changes: 4 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"strictNullChecks": true,
"target": "es2015",
"module": "commonjs",
"typeRoots": [
"./typings/globals"
]
}
"target": "es2015"
},
"files": ["index.d.ts"]
}
Loading