Skip to content

Commit 9e9f0fe

Browse files
emyannbidoubiwa
authored andcommitted
fix: allow to type the search response when using index search query
1 parent 730d7dc commit 9e9f0fe

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ class Index extends MeiliAxiosWrapper implements Types.IndexInterface {
7272
* @memberof Index
7373
* @method search
7474
*/
75-
async search(
75+
async search<T>(
7676
query: string,
7777
options?: Types.SearchParams
78-
): Promise<Types.SearchResponse> {
78+
): Promise<Types.SearchResponse<T>> {
7979
const url = `/indexes/${this.uid}/search`
8080

8181
const params: Types.SearchRequest = {

src/types.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ export interface IndexInterface extends MeiliAxiosWrapperInterface {
233233
uid: string
234234
getUpdateStatus: (updateId: number) => Promise<Update>
235235
getAllUpdateStatus: () => Promise<Update[]>
236-
search: (query: string, options?: SearchParams) => Promise<SearchResponse>
236+
search: <T>(
237+
query: string,
238+
options?: SearchParams
239+
) => Promise<SearchResponse<T>>
237240
show: () => Promise<IndexResponse>
238241
updateIndex: (data: UpdateIndexRequest) => Promise<IndexResponse>
239242
deleteIndex: () => Promise<string>
@@ -296,11 +299,11 @@ export interface MeiliAxiosWrapperInterface {
296299
data: IndexRequest,
297300
config?: AxiosRequestConfig
298301
) => Promise<IndexResponse>) &
299-
(<T = any, R = AxiosResponse<EnqueuedUpdate>>(
300-
url: string,
301-
data?: T,
302-
config?: AxiosRequestConfig
303-
) => Promise<R>)
302+
(<T = any, R = AxiosResponse<EnqueuedUpdate>>(
303+
url: string,
304+
data?: T,
305+
config?: AxiosRequestConfig
306+
) => Promise<R>)
304307
put: <T = any, R = AxiosResponse<T>>(
305308
url: string,
306309
data?: any,

0 commit comments

Comments
 (0)