Skip to content

Fix typing of testHook #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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