I am trying to create bindings for @testing-library/react-hooks. I have a playground where most of this is working but I am struggling to understand how to bind to Typescript parameters of type any
function renderHook(callback: (props?: any) => any, options?: RenderHookOptions): RenderHookResult
I have created a type that let’s me pass in parameters of any built-in type but only by binding to a single record type.
type initialValue<'props> = {initialValue: 'props}
Can someone explain how I can generalize the callback parameter so that I may pass random properties as is shown in the testing-library documentation
import { renderHook, act } from ‘@testing-library/react-hooks’
import useCounter from ‘./useCounter’
test(‘should reset counter to updated initial value’, () => {
const { result, rerender } = renderHook(({ initialValue }) => useCounter(initialValue), {
initialProps: { initialValue: 0 }
})
rerender({ initialValue: 10 })
act(() => {
result.current.reset()
})
expect(result.current.count).toBe(10)
})
All of the code is viewable on github
Oh, and by the way, does anyone know how to add Enabled Libraries to the playground’s settings? I would like to open @glennsl/rescript-jest and @ryyppy/rescript-promise.
Appreciative of any suggestions!