Skip to content

Commit

Permalink
🏷️(frontend) update typescript types
Browse files Browse the repository at this point in the history
We updated typescript to 5.7.2.
Some types were deprecated and we had to update them.
  • Loading branch information
AntoLC committed Nov 25, 2024
1 parent 041db6d commit b898ca0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ function hslToHex(h: number, s: number, l: number) {
return `#${f(0)}${f(8)}${f(4)}`;
}

export const toBase64 = (
str: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
) => Buffer.from(str).toString('base64');
export const toBase64 = (str: Uint8Array) =>
Buffer.from(str).toString('base64');
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export type RequestData = {
url: string;
method?: string;
headers: Record<string, string>;
body?: ArrayBuffer;
body?: ArrayBufferLike;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
};
Expand Down Expand Up @@ -48,12 +48,12 @@ export class RequestSerializer {
return new RequestSerializer(requestData);
}

public static arrayBufferToString(buffer: ArrayBuffer) {
public static arrayBufferToString(buffer: ArrayBufferLike) {
const decoder = new TextDecoder();
return decoder.decode(buffer);
return decoder.decode(buffer as ArrayBuffer);
}

public static arrayBufferToJson<T>(buffer: ArrayBuffer) {
public static arrayBufferToJson<T>(buffer: ArrayBufferLike) {
const jsonString = RequestSerializer.arrayBufferToString(buffer);
return JSON.parse(jsonString) as T;
}
Expand All @@ -64,7 +64,9 @@ export class RequestSerializer {
}

public static objectToArrayBuffer(ob: Record<string, unknown>) {
return RequestSerializer.stringToArrayBuffer(JSON.stringify(ob));
return RequestSerializer.stringToArrayBuffer(
JSON.stringify(ob),
) as ArrayBuffer;
}

constructor(requestData: RequestData) {
Expand All @@ -85,7 +87,7 @@ export class RequestSerializer {

toRequest(): Request {
const { url, ...rest } = this._requestData;
return new Request(url, rest);
return new Request(url, { ...rest, body: rest.body as BodyInit });
}

clone(): RequestSerializer {
Expand Down

0 comments on commit b898ca0

Please sign in to comment.