I am wrapping Angular's HttpClient service in my own method but still want users to be able to pass in options, however I can't seem to find a good way to reference that type in my own method parameter definition.
example:
constructor(private http: HttpClient) {}
my_request<T = any>(endpoint: string, payload: T, options: WhatTypeHere = {}) {
return this.http.post<MyHttpResponse>(this.build_url(endpoint), this.build_payload(payload), {
...options,
withCredentials: true,
});
}
You can see the options parameter of my_request() I don't know what I can put there so that when using my_request it can enforce it.
Here is the definition of HttpClient.post() fyi
post(url: string, body: any | null, options?: {
headers?: HttpHeaders | {
[header: string]: string | string[];
};
observe?: 'body';
params?: HttpParams | {
[param: string]: string | string[];
};
reportProgress?: boolean;
responseType?: 'json';
withCredentials?: boolean;
}): Observable<Object>;
I'm aware I could copy-paste that entire definition into my method, but if there is some way I can reference it I would rather for conciseness and if definitions change in the future.
One things I tried that didn't work was something like options: HttpClient['post']['options']
Is there anything thing like this I can use to reference that type?
interface?