From b78f9e823e8e0288dffa9dd7c3e6da34f997fc5a Mon Sep 17 00:00:00 2001 From: Choro Abdymanapov Date: Fri, 29 Sep 2023 15:01:04 +0300 Subject: [PATCH] fix: do not mutate descriptor --- src/main/ts/utils/deepmap.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/ts/utils/deepmap.ts b/src/main/ts/utils/deepmap.ts index 1871a1f..50fff89 100644 --- a/src/main/ts/utils/deepmap.ts +++ b/src/main/ts/utils/deepmap.ts @@ -20,14 +20,14 @@ export function deepMap( return } - const value = descriptor.get ? descriptor.get() : descriptor.value // descriptor cannot contain both accessor method and value // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#description - delete descriptor.get - delete descriptor.set + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { get, set, ...rest } = descriptor + const value = get ? get() : descriptor.value Object.defineProperty(n, key, { - ...descriptor, + ...rest, value: deepMap(value, fn, refs, key), }) })