Skip to content

Commit 092aaaa

Browse files
committed
Loosen up type-safety for props
1 parent 775fbb2 commit 092aaaa

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
@@ -152,6 +152,19 @@ export function testRenderHook() {
152152
unmount()
153153
}
154154

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

0 commit comments

Comments
 (0)