From 7474856dbad51b68af91b58a73239066fa690f92 Mon Sep 17 00:00:00 2001 From: Andrewmat Date: Mon, 11 Feb 2019 12:59:28 -0200 Subject: [PATCH 1/2] Adds typing for testHook return --- typings/index.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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. From f13288701e39aa258ed8c92c32dc9ebdd6e0f836 Mon Sep 17 00:00:00 2001 From: Andrewmat Date: Mon, 11 Feb 2019 19:52:10 -0200 Subject: [PATCH 2/2] Adds typings section to contributing.md --- CONTRIBUTING.md | 8 ++++++++ 1 file changed, 8 insertions(+) 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]