@@ -44,7 +44,7 @@ import { HttpRequests } from './http-requests'
4444import { Task , TaskClient } from './task'
4545import { EnqueuedTask } from './enqueued-task'
4646
47- class Index < T = Record < string , any > > {
47+ class Index < T extends Record < string , any > = Record < string , any > > {
4848 uid : string
4949 primaryKey : string | undefined
5050 createdAt : Date | undefined
@@ -76,11 +76,11 @@ class Index<T = Record<string, any>> {
7676 * @param config - Additional request configuration options
7777 * @returns Promise containing the search response
7878 */
79- async search < T = Record < string , any > > (
79+ async search < D = T > (
8080 query ?: string | null ,
8181 options ?: SearchParams ,
8282 config ?: Partial < Request >
83- ) : Promise < SearchResponse < T > > {
83+ ) : Promise < SearchResponse < D > > {
8484 const url = `indexes/${ this . uid } /search`
8585
8686 return await this . httpRequest . post (
@@ -99,11 +99,11 @@ class Index<T = Record<string, any>> {
9999 * @param config - Additional request configuration options
100100 * @returns Promise containing the search response
101101 */
102- async searchGet < T = Record < string , any > > (
102+ async searchGet < D = T > (
103103 query ?: string | null ,
104104 options ?: SearchParams ,
105105 config ?: Partial < Request >
106- ) : Promise < SearchResponse < T > > {
106+ ) : Promise < SearchResponse < D > > {
107107 const url = `indexes/${ this . uid } /search`
108108
109109 const parseFilter = ( filter ?: Filter ) : string | undefined => {
@@ -126,7 +126,7 @@ class Index<T = Record<string, any>> {
126126 attributesToHighlight : options ?. attributesToHighlight ?. join ( ',' ) ,
127127 }
128128
129- return await this . httpRequest . get < SearchResponse < T > > (
129+ return await this . httpRequest . get < SearchResponse < D > > (
130130 url ,
131131 removeUndefinedFromObject ( getParams ) ,
132132 config
0 commit comments