From ae99d86d8916f44990e5ea52fb619339d12fed58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TATSUNO=20=E2=80=9CTaz=E2=80=9D=20Yasuhiro?= Date: Fri, 1 Nov 2024 10:30:49 +0900 Subject: [PATCH] refactor: remove useless spread (#3600) * refactor: remove useless spread * refactor: remove useless spread fallback * refactor(adapter/lambda-edge): remove unneeded ternary operators * refactor: remove useless fallback --------- Co-authored-by: EdamAmex <121654029+EdamAme-x@users.noreply.github.com> --- src/adapter/lambda-edge/handler.ts | 2 +- src/client/client.ts | 10 +++------- src/middleware/jsx-renderer/index.ts | 3 ++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/adapter/lambda-edge/handler.ts b/src/adapter/lambda-edge/handler.ts index 12e58ccd..3f512d7b 100644 --- a/src/adapter/lambda-edge/handler.ts +++ b/src/adapter/lambda-edge/handler.ts @@ -141,7 +141,7 @@ const createResult = async (res: Response): Promise => { status: res.status.toString(), headers: convertHeaders(res.headers), body, - ...(isBase64Encoded ? { bodyEncoding: 'base64' } : {}), + ...(isBase64Encoded && { bodyEncoding: 'base64' }), } } diff --git a/src/client/client.ts b/src/client/client.ts index 2d5edeff..ec8eb24f 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -80,12 +80,8 @@ class ClientRequestImpl { let methodUpperCase = this.method.toUpperCase() const headerValues: Record = { - ...(args?.header ?? {}), - ...(typeof opt?.headers === 'function' - ? await opt.headers() - : opt?.headers - ? opt.headers - : {}), + ...args?.header, + ...(typeof opt?.headers === 'function' ? await opt.headers() : opt?.headers), } if (args?.cookie) { @@ -201,7 +197,7 @@ export const hc = >( const req = new ClientRequestImpl(url, method) if (method) { options ??= {} - const args = deepMerge(options, { ...(opts.args[1] ?? {}) }) + const args = deepMerge(options, { ...opts.args[1] }) return req.fetch(opts.args[0], args) } return req diff --git a/src/middleware/jsx-renderer/index.ts b/src/middleware/jsx-renderer/index.ts index 195a0229..bda5ce97 100644 --- a/src/middleware/jsx-renderer/index.ts +++ b/src/middleware/jsx-renderer/index.ts @@ -44,7 +44,8 @@ const createRenderer = ? jsx( (props: any) => component(props, c), { - ...{ Layout, ...(props as any) }, + Layout, + ...(props as any), }, children as any )