From 535b4b6c6e9dce4a24234bbadd311ac7974b23ad Mon Sep 17 00:00:00 2001 From: Maciej Pyrc Date: Sat, 6 Jul 2024 20:05:23 +0200 Subject: [PATCH] fix:types --- packages/core/src/request/request.ts | 13 +++++++------ packages/core/src/request/request.types.ts | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/core/src/request/request.ts b/packages/core/src/request/request.ts index dd108a09..903849cd 100644 --- a/packages/core/src/request/request.ts +++ b/packages/core/src/request/request.ts @@ -6,7 +6,6 @@ import { PayloadType, RequestJSON, RequestOptionsType, - ExtractRouteParams, sendRequest, RequestConfigurationType, PayloadMapperType, @@ -63,7 +62,7 @@ export class Request< headers?: HeadersInit; auth: boolean; method: ExtractAdapterMethodType; - params: ExtractRouteParams | NegativeTypes; + params: ExtractParamsType | NegativeTypes; data: PayloadType; queryParams: QueryParams | NegativeTypes; options?: ExtractAdapterOptionsType | undefined; @@ -180,7 +179,7 @@ export class Request< return this.clone({ auth }); }; - public setParams =

>(params: P) => { + public setParams =

>(params: P) => { return this.clone({ params }); }; @@ -429,6 +428,7 @@ export class Request< >( configuration?: RequestConfigurationType< Payload, + ExtractParamsType, QueryParams, Endpoint, ExtractAdapterOptionsType, @@ -450,6 +450,7 @@ export class Request< const json = this.toJSON(); const requestJSON: RequestConfigurationType< Payload, + ExtractParamsType, QueryParams, Endpoint, ExtractAdapterOptionsType, @@ -564,10 +565,10 @@ export class Request< * ``` */ public send: RequestSendType = async (options?: RequestSendOptionsType) => { - const { dispatcherType, ...rest } = options || {}; + const { dispatcherType, ...configuration } = options || {}; - const request = this.clone(rest); - return sendRequest(request, options); + const request = this.clone(configuration); + return sendRequest(request as this, options); }; } diff --git a/packages/core/src/request/request.types.ts b/packages/core/src/request/request.types.ts index 90905743..e6657761 100644 --- a/packages/core/src/request/request.types.ts +++ b/packages/core/src/request/request.types.ts @@ -178,13 +178,14 @@ export type PayloadType = Payload | NegativeTypes; export type RequestConfigurationType< Payload, + Params, QueryParams, GenericEndpoint extends string, AdapterOptions extends Record, MethodsType = HttpMethodsType, > = { used?: boolean; - params?: ExtractRouteParams | NegativeTypes; + params?: Params | NegativeTypes; queryParams?: QueryParams | NegativeTypes; data?: PayloadType; headers?: HeadersInit; @@ -223,7 +224,7 @@ export type FetchQueryParamsType = Params extends NegativeTypes - ? { params?: NegativeTypes } + ? { params?: never } : HasParams extends true ? { params?: NegativeTypes } : { params: Params };