From 15b2ca2384e1545a8a063af05557b463e30d8916 Mon Sep 17 00:00:00 2001 From: korkt-kim Date: Tue, 1 Sep 2026 21:18:28 +0900 Subject: [PATCH] fix: preserve generic query element types in render result --- types/index.d.ts | 8 ++++++-- types/test.tsx | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 439dddbf..55bf2af1 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -3,7 +3,7 @@ import * as ReactDOMClient from 'react-dom/client' import { queries, Queries, - BoundFunction, + BoundFunctions, prettyFormat, Config as ConfigDTL, } from '@testing-library/dom' @@ -44,7 +44,11 @@ export type RenderResult< rerender: (ui: React.ReactNode) => void unmount: () => void asFragment: () => DocumentFragment -} & {[P in keyof Q]: BoundFunction} +} & { + [P in keyof Q]: P extends keyof BoundFunctions + ? BoundFunctions[P] + : never +} /** @deprecated */ export type BaseRenderOptions< diff --git a/types/test.tsx b/types/test.tsx index 10e6c303..70429359 100644 --- a/types/test.tsx +++ b/types/test.tsx @@ -296,6 +296,44 @@ export function testErrorHandlers() { }) } +export async function testGenericQueryElementTypes() { + const view = pure.render(