Skip to content

Commit

Permalink
Loosen up type-safety for props
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Nov 22, 2021
1 parent b41cd68 commit 212e818
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ interface RenderHookOptions<Props> {

// TODO JSDOC
export function renderHook<Result, Props>(
render: (initialProps?: Props) => Result,
render: (initialProps: Props) => Result,
options?: RenderHookOptions<Props>,
): RenderHookResult<Result, Props>

Expand Down
13 changes: 13 additions & 0 deletions types/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ export function testRenderHook() {
unmount()
}

export function testRenderHookProps() {
const {result, rerender, unmount} = renderHook(
({defaultValue}) => React.useState(defaultValue)[0],
{initialProps: {defaultValue: 2}},
)

expectType<number, typeof result.current>(result.current)

rerender()

unmount()
}

/*
eslint
testing-library/prefer-explicit-assert: "off",
Expand Down

0 comments on commit 212e818

Please sign in to comment.