From e10f752c23eddc5ae5205354802ec2b975f5ced3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Jastrze=CC=A8bski?= Date: Thu, 1 Jan 2026 15:44:56 +0100 Subject: [PATCH] fix rest types --- src/render-async.tsx | 2 +- src/test-utils/json.ts | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/render-async.tsx b/src/render-async.tsx index de30bfbe..5ac03170 100644 --- a/src/render-async.tsx +++ b/src/render-async.tsx @@ -112,7 +112,7 @@ function makeDebug(renderer: Root): DebugFunction { function debugImpl(options?: DebugOptions) { const { defaultDebugOptions } = getConfig(); const debugOptions = { ...defaultDebugOptions, ...options }; - const json = renderer.toJSON(); + const json = renderer.container.toJSON(); if (json) { return debug(json, debugOptions); } diff --git a/src/test-utils/json.ts b/src/test-utils/json.ts index 2ecff910..5cfe9656 100644 --- a/src/test-utils/json.ts +++ b/src/test-utils/json.ts @@ -5,25 +5,26 @@ type JsonPropsMapper = { }; export function mapJsonProps( - element: T, + node: T, mapper: JsonPropsMapper, ): T { - if (Array.isArray(element)) { - return element.map((e) => mapJsonProps(e, mapper)) as T; + if (Array.isArray(node)) { + return node.map((e) => mapJsonProps(e, mapper)) as T; } - if (!element) { - return element; + if (!node || typeof node === 'string') { + return node; } - const resultProps = { ...element.props }; + const resultProps: Record = { ...node.props }; Object.keys(mapper).forEach((key) => { - if (key in element.props) { + if (key in node.props) { resultProps[key] = mapper[key]; } }); - const resultElement = { ...element, props: resultProps }; + // @ts-expect-error: TODO fix type + const resultElement = { ...node, props: resultProps }; Object.defineProperty(resultElement, '$$typeof', { value: Symbol.for('react.test.json'), });