diff --git a/types/sqlanywhere/index.d.ts b/types/sqlanywhere/index.d.ts new file mode 100644 index 0000000000..d56bfb7993 --- /dev/null +++ b/types/sqlanywhere/index.d.ts @@ -0,0 +1,48 @@ +// Type definitions for sqlanywhere 1.0 +// Project: https://github.com/sqlanywhere/node-sqlanywhere +// Definitions by: Peter Keuter +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export function createConnection(): SybaseConnection; + +export interface SybaseConnection { + connect( + params: ConnectionParameters, + cb: (err: Error | undefined) => void + ): void; + close(cb: (err?: Error) => void): void; + disconnect(cb: (err?: Error) => void): void; + connected(): boolean; + exec(query: string, cb: (err: Error | undefined, result: any) => void); + exec( + query: string, + placeholders: any[], + cb: (err: Error | undefined, result: any) => void + ); + prepare( + query: string, + cb: (err: Error | undefined, stmt: Statement) => void + ); + prepare(query: string): Statement; + commit(cb: (err: Error | undefined) => void): void; + rollback(cb: (err: Error | undefined) => void): void; +} + +export interface ConnectionParameters { + Server: string; + UserId: string; + DatabaseFile?: string; + AutoStart?: string; + Password: string; + Host?: string; +} + +export interface Statement { + exec(args: any[], cb: (err: Error | undefined, rows: any[]) => void); + exec(args: any[]): any[]; + getMoreResults(): any[]; + drop(cb: (err: Error | undefined) => void): void; +} +declare const _default: { + createConnection: typeof createConnection; +}; +export default _default; diff --git a/types/sqlanywhere/sqlanywhere-tests.ts b/types/sqlanywhere/sqlanywhere-tests.ts new file mode 100644 index 0000000000..b6151e77aa --- /dev/null +++ b/types/sqlanywhere/sqlanywhere-tests.ts @@ -0,0 +1,13 @@ +import sqlanywhere = require("sqlanywhere"); + +const connection: sqlanywhere.SybaseConnection = sqlanywhere.createConnection(); +connection.connect( + { + Host: "test", + UserId: "Test", + Password: "Test", + Server: "Test" + }, + err => err +); +connection.exec("SELECT * FROM TEST", (err, res) => res); diff --git a/types/sqlanywhere/tsconfig.json b/types/sqlanywhere/tsconfig.json new file mode 100644 index 0000000000..4270f0546c --- /dev/null +++ b/types/sqlanywhere/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitThis": true, + "noImplicitAny": false, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sqlanywhere-tests.ts" + ] +} diff --git a/types/sqlanywhere/tslint.json b/types/sqlanywhere/tslint.json new file mode 100644 index 0000000000..10d875b8db --- /dev/null +++ b/types/sqlanywhere/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "rules": {} +}