diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8642e953..89f9e343 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,14 @@ inside: pre-commit ``` +### Add typings + +If your PR introduced some changes in the API, you are more than welcome to +modify the Typescript type definition to reflect those changes. Just modify the +`/typings/index.d.ts` file accordingly. If you have never seen Typescript +definitions before, you can read more about it in its +[documentation pages](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html) + ## Help needed Please checkout the [the open issues][issues] diff --git a/typings/index.d.ts b/typings/index.d.ts index c87c817c..fa844fd2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -19,6 +19,11 @@ export type RenderResult = { asFragment: () => DocumentFragment } & {[P in keyof Q]: BoundFunction} +export type HookResult = { + rerender: () => void + unmount: () => boolean +} + export interface RenderOptions { container?: HTMLElement baseElement?: HTMLElement @@ -43,7 +48,7 @@ export function render( /** * Renders a test component that calls back to the test. */ -export function testHook(callback: () => void): void +export function testHook(callback: () => void): HookResult /** * Unmounts React trees that were mounted with render.