@@ -15,7 +15,7 @@ import { Deprecation } from './utils/Deprecation';
1515import { uuidv4 } from './utils/uuidv4' ;
1616import { proxify } from './utils/proxify' ;
1717import { debug } from './utils/debug' ;
18- import { JSONObject } from './types' ;
18+ import { BaseRequest , JSONObject } from './types' ;
1919import { RequestPayload } from './types/RequestPayload' ;
2020import { ResponsePayload } from './types/ResponsePayload' ;
2121import { RequestTimeoutError } from './RequestTimeoutError' ;
@@ -766,7 +766,10 @@ export class Kuzzle extends KuzzleEventEmitter {
766766 * @param req
767767 * @param opts - Optional arguments
768768 */
769- query ( req : RequestPayload = { } , opts : JSONObject = { } ) : Promise < ResponsePayload > {
769+ query < TRequest extends BaseRequest , TResult > (
770+ req : TRequest ,
771+ opts : JSONObject = { } ,
772+ ) : Promise < ResponsePayload < TResult > > {
770773 if ( typeof req !== 'object' || Array . isArray ( req ) ) {
771774 throw new Error ( `Kuzzle.query: Invalid request: ${ JSON . stringify ( req ) } ` ) ;
772775 }
@@ -857,7 +860,7 @@ Discarded request: ${JSON.stringify(request)}`));
857860 requestTimeout ,
858861 request ,
859862 options
860- ) . then ( ( response : ResponsePayload ) => {
863+ ) . then ( ( response : ResponsePayload < TResult > ) => {
861864 debug ( 'RESPONSE' , response ) ;
862865
863866 return this . deprecationHandler . logDeprecation ( response ) ;
0 commit comments