Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export interface RenderOptions<
*
* @see https://testing-library.com/docs/react-testing-library/api/#wrapper
*/
wrapper?: React.ComponentType
wrapper?:
| React.ComponentType
| ((props: {children: React.ReactNode}) => JSX.Element)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me add a type test for this because the fix is simpler I believe.

@eps1lon eps1lon Sep 27, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implicit children strikes again (DefinitelyTyped/DefinitelyTyped#34237):

React.ComponentType includes React.FunctionComponent which means the accepted props are { children?: React.ReactNode }. However, our Wrapper only accepts { children: React.ReactElement } props. So we could render <Wrapper>Some Child</Wrapper> which may not be implemented by the custom Wrapper component because now it receives { children: string }.

The proposed fix would not have fixed the linked issue (npm typecheck fails on ffa2221). dc03098 fixes the linked issue.

}

type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
Expand Down