Skip to content

Commit

Permalink
fix(clerk-js): Remove null type from Base.ts methods
Browse files Browse the repository at this point in the history
  • Loading branch information
desiprisg committed Nov 6, 2023
1 parent f7a773d commit ac1144b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/clerk-js/src/core/resources/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export abstract class BaseResource {
| ClerkResourceJSON[]
| DeletedObjectJSON
| DeletedObjectJSON[]
| ClerkPaginatedResponse<ClerkResourceJSON>
| null,
| ClerkPaginatedResponse<ClerkResourceJSON>,
>(requestInit: FapiRequestInit, opts: BaseFetchOptions = {}): Promise<FapiResponseJSON<J>> {
if (!BaseResource.fapiClient) {
clerkMissingFapiClientInResources();
Expand Down Expand Up @@ -105,7 +104,7 @@ export abstract class BaseResource {

protected abstract fromJSON(data: ClerkResourceJSON | null): this;

protected async _baseGet<J extends ClerkResourceJSON | null>(opts: BaseFetchOptions = {}): Promise<this> {
protected async _baseGet<J extends ClerkResourceJSON>(opts: BaseFetchOptions = {}): Promise<this> {
const json = await BaseResource._fetch<J>(
{
method: 'GET',
Expand All @@ -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<J extends ClerkResourceJSON | null>({
protected async _baseMutate<J extends ClerkResourceJSON>({
action,
body,
method = 'POST',
Expand All @@ -129,22 +128,22 @@ 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<J extends ClerkResourceJSON | null>(params: BaseMutateParams = {}): Promise<this> {
protected async _basePost<J extends ClerkResourceJSON>(params: BaseMutateParams = {}): Promise<this> {
return this._baseMutate<J>({ ...params, method: 'POST' });
}

protected async _basePut<J extends ClerkResourceJSON | null>(params: BaseMutateParams = {}): Promise<this> {
protected async _basePut<J extends ClerkResourceJSON>(params: BaseMutateParams = {}): Promise<this> {
return this._baseMutate<J>({ ...params, method: 'PUT' });
}

protected async _basePatch<J extends ClerkResourceJSON>(params: BaseMutateParams = {}): Promise<this> {
return this._baseMutate<J>({ ...params, method: 'PATCH' });
}

protected async _baseDelete<J extends ClerkResourceJSON | null>(params: BaseMutateParams = {}): Promise<void> {
protected async _baseDelete<J extends ClerkResourceJSON>(params: BaseMutateParams = {}): Promise<void> {
await this._baseMutate<J>({ ...params, method: 'DELETE' });
}

Expand Down

0 comments on commit ac1144b

Please sign in to comment.