mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Remove circular dependency between modules.
This commit is contained in:
42
pg-pool/pg-pool.d.ts
vendored
42
pg-pool/pg-pool.d.ts
vendored
@@ -3,48 +3,8 @@
|
||||
// Definitions by: Leo Liang <https://github.com/aleung>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../pg/pg.d.ts" />
|
||||
|
||||
declare module "pg-pool" {
|
||||
import * as events from "events";
|
||||
import * as stream from "stream";
|
||||
import * as pg from "pg";
|
||||
|
||||
export interface PoolConfig extends pg.ClientConfig {
|
||||
// properties from module 'node-pool'
|
||||
max?: number;
|
||||
min?: number;
|
||||
refreshIdle?: boolean;
|
||||
idleTimeoutMillis?: number;
|
||||
reapIntervalMillis?: number;
|
||||
returnToHead?: boolean;
|
||||
}
|
||||
|
||||
export class Pool extends events.EventEmitter {
|
||||
|
||||
constructor();
|
||||
|
||||
// `new Pool('pg://user@localhost/mydb')` is not allowed.
|
||||
// But it passes type check because of issue:
|
||||
// https://github.com/Microsoft/TypeScript/issues/7485
|
||||
constructor(config: PoolConfig);
|
||||
|
||||
connect(): Promise<pg.Client>;
|
||||
connect(callback: (err: Error, client: pg.Client, done: () => void) => void): void;
|
||||
|
||||
end(): Promise<void>;
|
||||
|
||||
query(queryText: string): Promise<pg.QueryResult>;
|
||||
query(queryText: string, values: any[]): Promise<pg.QueryResult>;
|
||||
|
||||
query(queryText: string, callback: (err: Error, result: pg.QueryResult) => void): void;
|
||||
query(queryText: string, values: any[], callback: (err: Error, result: pg.QueryResult) => void): void;
|
||||
|
||||
public on(event: "error", listener: (err: Error, client: pg.Client) => void): this;
|
||||
public on(event: "connect", listener: (client: pg.Client) => void): this;
|
||||
public on(event: "acquire", listener: (client: pg.Client) => void): this;
|
||||
public on(event: string, listener: Function): this;
|
||||
}
|
||||
|
||||
export {Pool, PoolConfig} from "pg";
|
||||
}
|
||||
|
||||
39
pg/pg.d.ts
vendored
39
pg/pg.d.ts
vendored
@@ -4,14 +4,11 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../pg-pool/pg-pool.d.ts" />
|
||||
|
||||
declare module "pg" {
|
||||
import events = require("events");
|
||||
import stream = require("stream");
|
||||
|
||||
export {Pool, PoolConfig} from "pg-pool";
|
||||
|
||||
export function connect(connection: string, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void;
|
||||
export function connect(config: ClientConfig, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void;
|
||||
export function end(): void;
|
||||
@@ -36,6 +33,16 @@ declare module "pg" {
|
||||
ssl?: boolean;
|
||||
}
|
||||
|
||||
export interface PoolConfig extends ClientConfig {
|
||||
// properties from module 'node-pool'
|
||||
max?: number;
|
||||
min?: number;
|
||||
refreshIdle?: boolean;
|
||||
idleTimeoutMillis?: number;
|
||||
reapIntervalMillis?: number;
|
||||
returnToHead?: boolean;
|
||||
}
|
||||
|
||||
export interface QueryConfig {
|
||||
name?: string;
|
||||
text: string;
|
||||
@@ -53,6 +60,32 @@ declare module "pg" {
|
||||
addRow(row: any): void;
|
||||
}
|
||||
|
||||
export class Pool extends events.EventEmitter {
|
||||
|
||||
constructor();
|
||||
|
||||
// `new Pool('pg://user@localhost/mydb')` is not allowed.
|
||||
// But it passes type check because of issue:
|
||||
// https://github.com/Microsoft/TypeScript/issues/7485
|
||||
constructor(config: PoolConfig);
|
||||
|
||||
connect(): Promise<Client>;
|
||||
connect(callback: (err: Error, client: Client, done: () => void) => void): void;
|
||||
|
||||
end(): Promise<void>;
|
||||
|
||||
query(queryText: string): Promise<QueryResult>;
|
||||
query(queryText: string, values: any[]): Promise<QueryResult>;
|
||||
|
||||
query(queryText: string, callback: (err: Error, result: QueryResult) => void): void;
|
||||
query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): void;
|
||||
|
||||
public on(event: "error", listener: (err: Error, client: Client) => void): this;
|
||||
public on(event: "connect", listener: (client: Client) => void): this;
|
||||
public on(event: "acquire", listener: (client: Client) => void): this;
|
||||
public on(event: string, listener: Function): this;
|
||||
}
|
||||
|
||||
export class Client extends events.EventEmitter {
|
||||
constructor(connection: string);
|
||||
constructor(config: ClientConfig);
|
||||
|
||||
Reference in New Issue
Block a user