Updated typings (#819)
This commit is contained in:
committed by
GitHub
parent
72fda2bdd5
commit
c6ce062822
20
index.d.ts
vendored
20
index.d.ts
vendored
@ -27,7 +27,8 @@ import Transport, {
|
|||||||
TransportRequestParams,
|
TransportRequestParams,
|
||||||
TransportRequestOptions,
|
TransportRequestOptions,
|
||||||
nodeFilterFn,
|
nodeFilterFn,
|
||||||
nodeSelectorFn
|
nodeSelectorFn,
|
||||||
|
TransportRequestCallback
|
||||||
} from './lib/Transport';
|
} from './lib/Transport';
|
||||||
import Connection, { AgentOptions, agentFn } from './lib/Connection';
|
import Connection, { AgentOptions, agentFn } from './lib/Connection';
|
||||||
import ConnectionPool, { ResurrectEvent } from './lib/ConnectionPool';
|
import ConnectionPool, { ResurrectEvent } from './lib/ConnectionPool';
|
||||||
@ -38,12 +39,18 @@ import * as errors from './lib/errors';
|
|||||||
declare type anyObject = {
|
declare type anyObject = {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
declare type callbackFn = (err: Error | null, result: ApiResponse) => void;
|
|
||||||
|
|
||||||
interface ApiMethod<T> {
|
declare type callbackFn<T> = (err: Error | null, result: ApiResponse<T>) => void;
|
||||||
(callback?: callbackFn): any;
|
|
||||||
(params: T, callback?: callbackFn): any;
|
interface ApiMethod<TParams, TBody = any> {
|
||||||
(params: T, options: TransportRequestOptions, callback?: callbackFn): any;
|
// Promise API
|
||||||
|
(): Promise<ApiResponse<TBody>>;
|
||||||
|
(params: TParams): Promise<ApiResponse<TBody>>;
|
||||||
|
(params: TParams, options: TransportRequestOptions): Promise<ApiResponse<TBody>>;
|
||||||
|
// Callback API
|
||||||
|
(callback: callbackFn<TBody>): TransportRequestCallback;
|
||||||
|
(params: TParams, callback: callbackFn<TBody>): TransportRequestCallback;
|
||||||
|
(params: TParams, options: TransportRequestOptions, callback: callbackFn<TBody>): TransportRequestCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extend API
|
// Extend API
|
||||||
@ -604,5 +611,6 @@ export {
|
|||||||
RequestEvent,
|
RequestEvent,
|
||||||
ResurrectEvent,
|
ResurrectEvent,
|
||||||
RequestParams,
|
RequestParams,
|
||||||
|
ClientOptions,
|
||||||
ClientExtendsCallbackOptions
|
ClientExtendsCallbackOptions
|
||||||
};
|
};
|
||||||
|
|||||||
7
lib/Transport.d.ts
vendored
7
lib/Transport.d.ts
vendored
@ -96,6 +96,10 @@ export interface TransportRequestOptions {
|
|||||||
warnings?: [string];
|
warnings?: [string];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TransportRequestCallback {
|
||||||
|
abort: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
export default class Transport {
|
export default class Transport {
|
||||||
static sniffReasons: {
|
static sniffReasons: {
|
||||||
SNIFF_ON_START: string;
|
SNIFF_ON_START: string;
|
||||||
@ -117,7 +121,8 @@ export default class Transport {
|
|||||||
_nextSniff: number;
|
_nextSniff: number;
|
||||||
_isSniffing: boolean;
|
_isSniffing: boolean;
|
||||||
constructor(opts: TransportOptions);
|
constructor(opts: TransportOptions);
|
||||||
request(params: TransportRequestParams, options: TransportRequestOptions, callback: (err: Error | null, result: ApiResponse) => void): any;
|
request(params: TransportRequestParams, options?: TransportRequestOptions): Promise<ApiResponse>;
|
||||||
|
request(params: TransportRequestParams, options?: TransportRequestOptions, callback?: (err: Error | null, result: ApiResponse) => void): TransportRequestCallback;
|
||||||
getConnection(): Connection | null;
|
getConnection(): Connection | null;
|
||||||
sniff(callback?: (...args: any[]) => void): void;
|
sniff(callback?: (...args: any[]) => void): void;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user