Skip to content

Commit 850a3f7

Browse files
committed
Loosen up type-safety for props
1 parent 3d81844 commit 850a3f7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ interface RenderHookOptions<Props> {
110110

111111
// TODO JSDOC
112112
export function renderHook<Result, Props>(
113-
render: (initialProps?: Props) => Result,
113+
render: (initialProps: Props) => Result,
114114
options?: RenderHookOptions<Props>,
115115
): RenderHookResult<Result, Props>
116116

types/test.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ export function testRenderHook() {
110110
unmount()
111111
}
112112

113+
export function testRenderHookProps() {
114+
const {result, rerender, unmount} = renderHook(
115+
({defaultValue}) => React.useState(defaultValue)[0],
116+
{initialProps: {defaultValue: 2}},
117+
)
118+
119+
expectType<number, typeof result.current>(result.current)
120+
121+
rerender()
122+
123+
unmount()
124+
}
125+
113126
/*
114127
eslint
115128
testing-library/prefer-explicit-assert: "off",

0 commit comments

Comments
 (0)