From ae73505d0e2d653a8898965422bf5d6dc2f8aaf5 Mon Sep 17 00:00:00 2001 From: Ariel Caplan Date: Mon, 9 Dec 2024 21:30:54 +0200 Subject: [PATCH] Remove copying mechanism which falsely suggests immutability In fact it's just a second reference to the same thing after the code changes in the previous commit. So it would be better to avoid suggesting that changes are safe. --- .../cli/services/app/write-app-configuration-file.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/app/src/cli/services/app/write-app-configuration-file.ts b/packages/app/src/cli/services/app/write-app-configuration-file.ts index db9382f215a..4dd48d98454 100644 --- a/packages/app/src/cli/services/app/write-app-configuration-file.ts +++ b/packages/app/src/cli/services/app/write-app-configuration-file.ts @@ -28,20 +28,18 @@ export async function writeAppConfigurationFile(configuration: CurrentAppConfigu } export const rewriteConfiguration = (schema: T, config: unknown): unknown => { - const configCopy = config - if (schema === null || schema === undefined) return null if (schema instanceof zod.ZodNullable || schema instanceof zod.ZodOptional) - return rewriteConfiguration(schema.unwrap(), configCopy) + return rewriteConfiguration(schema.unwrap(), config) if (schema instanceof zod.ZodArray) { - return (configCopy as unknown[]).map((item) => rewriteConfiguration(schema.element, item)) + return (config as unknown[]).map((item) => rewriteConfiguration(schema.element, item)) } if (schema instanceof zod.ZodEffects) { - return rewriteConfiguration(schema._def.schema, configCopy) + return rewriteConfiguration(schema._def.schema, config) } if (schema instanceof zod.ZodObject) { const entries = Object.entries(schema.shape) - const confObj = configCopy as {[key: string]: unknown} + const confObj = config as {[key: string]: unknown} let result: {[key: string]: unknown} = {} entries.forEach(([key, subSchema]) => { if (confObj !== undefined && confObj[key] !== undefined) {