From ac1144bb73b69453f437051e02889983f6d5aae3 Mon Sep 17 00:00:00 2001 From: George Desipris Date: Mon, 6 Nov 2023 12:13:57 +0200 Subject: [PATCH] fix(clerk-js): Remove null type from Base.ts methods --- packages/clerk-js/src/core/resources/Base.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/clerk-js/src/core/resources/Base.ts b/packages/clerk-js/src/core/resources/Base.ts index d8d297cd4ed..0af7b04e9c7 100644 --- a/packages/clerk-js/src/core/resources/Base.ts +++ b/packages/clerk-js/src/core/resources/Base.ts @@ -35,8 +35,7 @@ export abstract class BaseResource { | ClerkResourceJSON[] | DeletedObjectJSON | DeletedObjectJSON[] - | ClerkPaginatedResponse - | null, + | ClerkPaginatedResponse, >(requestInit: FapiRequestInit, opts: BaseFetchOptions = {}): Promise> { if (!BaseResource.fapiClient) { clerkMissingFapiClientInResources(); @@ -105,7 +104,7 @@ export abstract class BaseResource { protected abstract fromJSON(data: ClerkResourceJSON | null): this; - protected async _baseGet(opts: BaseFetchOptions = {}): Promise { + protected async _baseGet(opts: BaseFetchOptions = {}): Promise { const json = await BaseResource._fetch( { method: 'GET', @@ -115,10 +114,10 @@ export abstract class BaseResource { opts, ); - return this.fromJSON((json?.response || json) as J); + return this.fromJSON(json?.response || json); } - protected async _baseMutate({ + protected async _baseMutate({ action, body, method = 'POST', @@ -129,14 +128,14 @@ export abstract class BaseResource { path: path || this.path(action), body, }); - return this.fromJSON((json?.response || json) as J); + return this.fromJSON(json?.response || json); } - protected async _basePost(params: BaseMutateParams = {}): Promise { + protected async _basePost(params: BaseMutateParams = {}): Promise { return this._baseMutate({ ...params, method: 'POST' }); } - protected async _basePut(params: BaseMutateParams = {}): Promise { + protected async _basePut(params: BaseMutateParams = {}): Promise { return this._baseMutate({ ...params, method: 'PUT' }); } @@ -144,7 +143,7 @@ export abstract class BaseResource { return this._baseMutate({ ...params, method: 'PATCH' }); } - protected async _baseDelete(params: BaseMutateParams = {}): Promise { + protected async _baseDelete(params: BaseMutateParams = {}): Promise { await this._baseMutate({ ...params, method: 'DELETE' }); }