Skip to content

Commit a3f6510

Browse files
committed
Loosen up type-safety for props
1 parent a842157 commit a3f6510

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ interface RenderHookOptions<Props> {
105105

106106
// TODO JSDOC
107107
export function renderHook<Result, Props>(
108-
render: (initialProps?: Props) => Result,
108+
render: (initialProps: Props) => Result,
109109
options?: RenderHookOptions<Props>,
110110
): RenderHookResult<Result, Props>
111111

types/test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ export function testRenderHook() {
151151
unmount()
152152
}
153153

154+
export function testRenderHookProps() {
155+
const {result, rerender, unmount} = renderHook(
156+
({defaultValue}) => React.useState(defaultValue)[0],
157+
{initialProps: {defaultValue: 2}},
158+
)
159+
160+
expectType<number, typeof result.current>(result.current)
161+
162+
rerender()
163+
164+
unmount()
165+
}
166+
154167
/*
155168
eslint
156169
testing-library/prefer-explicit-assert: "off",

0 commit comments

Comments
 (0)