Skip to content

Commit

Permalink
updating TypeScript.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed May 31, 2017
1 parent 7c2010c commit 39c926a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
11 changes: 6 additions & 5 deletions test/typescript/init.ts
Expand Up @@ -4,7 +4,8 @@ import {IConnectionParameters} from "../../typescript/pg-subset";
var pgp: pgPromise.IMain = pgPromise({
capSQL: true,
pgFormatting: true,
pgNative: true
pgNative: true,
poolStrategy: "user"
});

var c: pgPromise.IConfig;
Expand All @@ -18,12 +19,12 @@ interface Test {
hello: string;
}

var db = <pgPromise.IDatabase<Test>&Test>pgp('connection');
var db = <pgPromise.IDatabase<Test> & Test>pgp('connection');

var connection1:string = <string>db.$cn;
var connection2:IConnectionParameters = <IConnectionParameters>db.$cn;
var connection1: string = <string>db.$cn;
var connection2: IConnectionParameters = <IConnectionParameters>db.$cn;

var context:any = db.$dc;
var context: any = db.$dc;

db.one('');

Expand Down
2 changes: 1 addition & 1 deletion typescript/ext-promise.d.ts
Expand Up @@ -32,4 +32,4 @@
*/

export=Promise; // Using ES6 Promise by default
export = Promise; // Using ES6 Promise by default
5 changes: 4 additions & 1 deletion typescript/pg-promise.d.ts
@@ -1,5 +1,5 @@
////////////////////////////////////////
// Requires pg-promise v5.8.0 or later.
// Requires pg-promise v6.0.1 or later.
////////////////////////////////////////

import * as XPromise from './ext-promise'; // External Promise Provider
Expand Down Expand Up @@ -121,6 +121,8 @@ declare namespace pgPromise {
options?: TFormattingOptions
};

type PoolStrategy = 'single' | 'machine' | 'server' | 'database' | 'user';

interface IArrayExt<T> extends Array<T> {
duration: number;
}
Expand Down Expand Up @@ -541,6 +543,7 @@ declare namespace pgPromise {
pgFormatting?: boolean;
pgNative?: boolean,
promiseLib?: any;
poolStrategy?: PoolStrategy;
connect?: (client: pg.Client, dc: any, fresh: boolean) => void;
disconnect?: (client: pg.Client, dc: any) => void;
query?: (e: IEventContext) => void;
Expand Down
20 changes: 10 additions & 10 deletions typescript/pg-subset.d.ts
Expand Up @@ -44,13 +44,13 @@ declare namespace pg {
// For property types and documentation see:
// http://nodejs.org/api/tls.html#tls_tls_connect_options_callback
interface ISSLConfig {
ca?: string|string[]|Buffer|Buffer[];
pfx?: string|Buffer;
cert?: string|string[]|Buffer|Buffer[];
key?: string|string[]|Buffer|Object[];
ca?: string | string[] | Buffer | Buffer[];
pfx?: string | Buffer;
cert?: string | string[] | Buffer | Buffer[];
key?: string | string[] | Buffer | Object[];
passphrase?: string;
rejectUnauthorized?: boolean;
NPNProtocols?: string[]|Buffer;
NPNProtocols?: string[] | Buffer;
}

interface IConnectionParameters {
Expand All @@ -59,7 +59,7 @@ declare namespace pg {
password?: string;
port?: number;
host?: string;
ssl?: boolean|ISSLConfig;
ssl?: boolean | ISSLConfig;
binary?: boolean;
client_encoding?: string;
application_name?: string;
Expand All @@ -70,7 +70,7 @@ declare namespace pg {
// Interface of 'pg-types' module;
// See: https://github.com/brianc/node-pg-types
interface ITypes {
setTypeParser: (oid: number, format: string|((value: string) => any)) => void;
setTypeParser: (oid: number, format: string | ((value: string) => any)) => void;
getTypeParser: (oid: number, format?: string) => any;
arrayParser: (source: string, transform: (entry: any) => any) => Array<any>;
}
Expand Down Expand Up @@ -115,7 +115,7 @@ declare namespace pg {

client_encoding: string,

ssl: boolean|ISSLConfig,
ssl: boolean | ISSLConfig,

application_name?: string,

Expand Down Expand Up @@ -155,7 +155,7 @@ declare namespace pg {

queryQueue: Array<Query>;
binary: boolean;
ssl: boolean|ISSLConfig;
ssl: boolean | ISSLConfig;
secretKey: number;
processID: number;
encoding: string;
Expand All @@ -167,4 +167,4 @@ declare namespace pg {
var types: ITypes;
}

export=pg;
export = pg;

0 comments on commit 39c926a

Please sign in to comment.