Skip to content

Export options types and renderHook result type #1034

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

Closed
wants to merge 3 commits into from

Conversation

evanwalsh
Copy link

Summary

While writing helpers around the render and renderHook functions, I found myself wanting/needing the types for the options and the returns. This explicitly exports those types that weren't already exposed to avoid having to do something like the following:

type RenderOptions = Parameters<typeof render>[1]
type RenderHookOptions = Parameters<typeof renderHook>[1]

// Copied/pasted from @testing-library/react-native
interface RenderHookResult<Result, Props> {
  result: {current: Result}
  rerender: (props: Props) => void
  unmount: () => void
}

These types are already documented, so this just fully exposes types that are already meant for users.

Test plan

I'm not sure what additional tests would be needed for this. As long as type checking succeeds, these changes should be good.

Copy link
Member

@mdjastrzebski mdjastrzebski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evanwalsh thanks for submitting the PR. I guess it makes sens to export these types. The chosen names also seem correct.

You need to add export clauses to pure.js or otherwise users will not be able to directly import these types from @testing-library/react-native

@evanwalsh evanwalsh requested a review from mdjastrzebski August 9, 2022 13:59
Copy link
Member

@mdjastrzebski mdjastrzebski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there :-)

@@ -20,5 +20,5 @@ export { waitFor };
export { waitForElementToBeRemoved };
export { within, getQueriesForElement };
export { getDefaultNormalizer };
export { renderHook };
export { renderHook, RenderHookOptions, RenderHookResult };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Export RenderHookOptions, RenderHookResult as export type next to other export type declarations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants