Skip to content

Commit

Permalink
fix(TS): typing of testHook (#292)
Browse files Browse the repository at this point in the history
* Adds typing for testHook return

* Adds typings section to contributing.md
  • Loading branch information
Andrewmat authored and Kent C. Dodds committed Feb 11, 2019
1 parent 9c606da commit 8436c7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -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]
Expand Down
7 changes: 6 additions & 1 deletion typings/index.d.ts
Expand Up @@ -19,6 +19,11 @@ export type RenderResult<Q extends Queries = typeof queries> = {
asFragment: () => DocumentFragment
} & {[P in keyof Q]: BoundFunction<Q[P]>}

export type HookResult = {
rerender: () => void
unmount: () => boolean
}

export interface RenderOptions<Q extends Queries = typeof queries> {
container?: HTMLElement
baseElement?: HTMLElement
Expand All @@ -43,7 +48,7 @@ export function render<Q extends Queries>(
/**
* 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.
Expand Down

0 comments on commit 8436c7e

Please sign in to comment.