Chore: add generics to backendSrv (#51606)

This commit is contained in:
Ryan McKinley
2022-06-30 14:34:23 -04:00
committed by GitHub
parent d59db0b8e6
commit 281ed419a8
5 changed files with 38 additions and 35 deletions
@@ -143,17 +143,17 @@ export function isFetchError(e: unknown): e is FetchError {
* @public
*/
export interface BackendSrv {
get(url: string, params?: any, requestId?: string): Promise<any>;
delete(url: string, data?: any): Promise<any>;
post(url: string, data?: any): Promise<any>;
patch(url: string, data?: any): Promise<any>;
put(url: string, data?: any): Promise<any>;
get<T = any>(url: string, params?: any, requestId?: string): Promise<T>;
delete<T = any>(url: string, data?: any): Promise<T>;
post<T = any>(url: string, data?: any): Promise<T>;
patch<T = any>(url: string, data?: any): Promise<T>;
put<T = any>(url: string, data?: any): Promise<T>;
/**
* @deprecated Use the fetch function instead. If you prefer to work with a promise
* wrap the Observable returned by fetch with the lastValueFrom function.
*/
request(options: BackendSrvRequest): Promise<any>;
request<T = any>(options: BackendSrvRequest): Promise<T>;
/**
* Special function used to communicate with datasources that will emit core