mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add types for mysql-import (#38762)
This commit is contained in:
parent
837bb465c9
commit
8501cb5b3e
40
types/mysql-import/index.d.ts
vendored
Normal file
40
types/mysql-import/index.d.ts
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
// Type definitions for mysql-import 2.0
|
||||
// Project: https://github.com/pamblam/mysql-import#readme
|
||||
// Definitions by: Ben Grynhaus <https://github.com/bengry>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Settings {
|
||||
/**
|
||||
* The MySQL host to connect to.
|
||||
*/
|
||||
host: string;
|
||||
/**
|
||||
* The MySQL port to connect to.
|
||||
*/
|
||||
port?: number;
|
||||
/**
|
||||
* The MySQL user to connect with.
|
||||
*/
|
||||
user: string;
|
||||
/**
|
||||
* The password for the user.
|
||||
*/
|
||||
password: string;
|
||||
/**
|
||||
* The database to connect to.
|
||||
*/
|
||||
database: string;
|
||||
/**
|
||||
* Function to handle errors. The function will receive the Error. If not provided the error will be thrown.
|
||||
*/
|
||||
onerror?(error: any): void;
|
||||
}
|
||||
|
||||
export interface Importer {
|
||||
/**
|
||||
* Import an .sql file to the database.
|
||||
*/
|
||||
import(filename: string): Promise<void>;
|
||||
}
|
||||
|
||||
export function config(settings: Settings): Importer;
|
||||
17
types/mysql-import/mysql-import-tests.ts
Normal file
17
types/mysql-import/mysql-import-tests.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import * as mysqlImport from 'mysql-import';
|
||||
|
||||
mysqlImport.config(); // $ExpectError
|
||||
|
||||
mysqlImport.config({}); // $ExpectError
|
||||
|
||||
// $ExpectType Importer
|
||||
const importer = mysqlImport.config({
|
||||
host: 'localhost',
|
||||
port: 1234,
|
||||
user: 'user',
|
||||
password: 'test',
|
||||
database: 'database',
|
||||
onerror: err => {},
|
||||
});
|
||||
|
||||
importer.import('sql-file-path'); // $ExpectType Promise<void>
|
||||
23
types/mysql-import/tsconfig.json
Normal file
23
types/mysql-import/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"mysql-import-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/mysql-import/tslint.json
Normal file
1
types/mysql-import/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user