Skip to content

fix: type RenderHookOptions.wrapper with preact ComponentChildren#82

Open
akselinurmio wants to merge 1 commit into
testing-library:mainfrom
akselinurmio:fix/renderhook-wrapper-type
Open

fix: type RenderHookOptions.wrapper with preact ComponentChildren#82
akselinurmio wants to merge 1 commit into
testing-library:mainfrom
akselinurmio:fix/renderhook-wrapper-type

Conversation

@akselinurmio

Copy link
Copy Markdown

Summary

Fixes #81.

RenderHookOptions.wrapper was typed as ComponentType<{ children: Element }>. Here Element resolves to the DOM Element global rather than a preact/JSX type, so a normal wrapper component (context providers, etc.) typed with ComponentChildren / PropsWithChildren is not assignable, producing a TS2322 error at every renderHook call that passes a wrapper.

This changes the type to ComponentType<{ children?: ComponentChildren }>, using preact's ComponentChildren and making children optional, matching how wrapper components are actually typed.

Changes

  • Import ComponentChildren from preact.
  • wrapper?: ComponentType<{ children: Element }>wrapper?: ComponentType<{ children?: ComponentChildren }>.

Testing

  • npm test — 13 suites / 104 tests pass.
  • npm run build — CJS + ESM compile successfully.

The change is type-only; no runtime code changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RenderHookOptions.wrapper typed as ComponentType<{ children: Element }> — should use a preact type

1 participant