react-hooks-testing-library version: 3.2.1react-test-renderer version: 16.12.0react version: 16.12.0node version: 12.13.1npm version: 6.12.1let your = (code, tell) => `the ${story}`
Using Typescript:
const { wait } = renderHook(() =>
I get this error 'wait' is declared but its value is never read.
type definitions is no up to date
Somehow update type definition because the current definition for the v3.2.1 is
// Type definitions for @testing-library/react-hooks 3.1
// Project: https://github.com/testing-library/react-hooks-testing-library
// Definitions by: Michael Peyper <https://github.com/mpeyper>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { ComponentType } from 'react';
export { act } from 'react-test-renderer';
export interface RenderHookOptions<P> {
initialProps?: P;
wrapper?: React.ComponentType;
}
export interface HookResult<R> {
readonly current: R;
readonly error: Error;
}
export interface RenderHookResult<P, R> {
readonly result: HookResult<R>;
readonly waitForNextUpdate: () => Promise<void>;
readonly unmount: () => boolean;
readonly rerender: (newProps?: P) => void;
}
/**
* Renders a test component that will call the provided `callback`, including any hooks it calls, every time it renders.
*/
export function renderHook<P, R>(callback: (props: P) => R, options?: RenderHookOptions<P>): RenderHookResult<P, R>;
/**
* Unmounts any rendered hooks rendered with `renderHook`, ensuring all effects have been flushed.
*/
export function cleanup(): Promise<void>;
The types have moved to DefinitelyTyped to be maintained by the typescript community.
Please open an issue in that repo and consider making a contribution to update the types. I'll gladly review PRs to update them.
I'm happy to keep this open until they are brought up to date.
Hi there. I've added the type information for wait and waitForValueToChange, based on the given signatures from the documentation.
PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/41028
The branch is merged on DT, you can close this 馃檪
Thank you @sarahdayan. If you want to, you can open a PR to add yourself as a contributor. I'm not sure which type best suits type definitions, perhaps platform or plugin, but feel free to choose whatever you think is most appropriate.
Most helpful comment
Hi there. I've added the type information for
waitandwaitForValueToChange, based on the given signatures from the documentation.PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/41028