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,
|
||||
TransportRequestOptions,
|
||||
nodeFilterFn,
|
||||
nodeSelectorFn
|
||||
nodeSelectorFn,
|
||||
TransportRequestCallback
|
||||
} from './lib/Transport';
|
||||
import Connection, { AgentOptions, agentFn } from './lib/Connection';
|
||||
import ConnectionPool, { ResurrectEvent } from './lib/ConnectionPool';
|
||||
@ -38,12 +39,18 @@ import * as errors from './lib/errors';
|
||||
declare type anyObject = {
|
||||
[key: string]: any;
|
||||
};
|
||||
declare type callbackFn = (err: Error | null, result: ApiResponse) => void;
|
||||
|
||||
interface ApiMethod<T> {
|
||||
(callback?: callbackFn): any;
|
||||
(params: T, callback?: callbackFn): any;
|
||||
(params: T, options: TransportRequestOptions, callback?: callbackFn): any;
|
||||
declare type callbackFn<T> = (err: Error | null, result: ApiResponse<T>) => void;
|
||||
|
||||
interface ApiMethod<TParams, TBody = 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
|
||||
@ -604,5 +611,6 @@ export {
|
||||
RequestEvent,
|
||||
ResurrectEvent,
|
||||
RequestParams,
|
||||
ClientOptions,
|
||||
ClientExtendsCallbackOptions
|
||||
};
|
||||
|
||||
7
lib/Transport.d.ts
vendored
7
lib/Transport.d.ts
vendored
@ -96,6 +96,10 @@ export interface TransportRequestOptions {
|
||||
warnings?: [string];
|
||||
}
|
||||
|
||||
export interface TransportRequestCallback {
|
||||
abort: () => void;
|
||||
}
|
||||
|
||||
export default class Transport {
|
||||
static sniffReasons: {
|
||||
SNIFF_ON_START: string;
|
||||
@ -117,7 +121,8 @@ export default class Transport {
|
||||
_nextSniff: number;
|
||||
_isSniffing: boolean;
|
||||
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;
|
||||
sniff(callback?: (...args: any[]) => void): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user