Skip to content

fix(TS): export Queries interface #396

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

Conversation

NMinhNguyen
Copy link
Contributor

@NMinhNguyen NMinhNguyen commented Jun 25, 2019

What: Export Queries interface to make it easier to define a custom render, e.g.

import { render } from '@my-design-system/test-utils'
// Pass in a custom theme which the custom `render` wires up to a `ThemeProvider`
render(<MyDesignSystemButton />, { theme: { someColor: 'blue' } })

Why: Closes #395.

How: Export Queries interface which is referenced by render in index.d.ts.

Checklist:

  • Documentation added to the
    docs site
  • Tests
  • Typescript definitions updated
  • Ready to be merged

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

That seems reasonable to me! Thanks!

@kentcdodds kentcdodds merged commit 566dd15 into testing-library:master Jun 25, 2019
@kentcdodds
Copy link
Member

@all-contributors please add @NMinhNguyen for code

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @NMinhNguyen! 🎉

@kentcdodds
Copy link
Member

🎉 This PR is included in version 8.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@NMinhNguyen
Copy link
Contributor Author

NMinhNguyen commented Jun 25, 2019

That seems reasonable to me! Thanks!

Actually @kentcdodds upon further investigation, it seems like it was some kinda misconfiguration issue at work (can't seem to repro, however) where it threw an error using a much older version of RTL (5.5.3), and it doesn't seem to throw on 8.0.2 (the one before you kindly cut 8.0.3).. When comparing the two index.d.ts files, I saw that Queries wasn't being exported in either version, so just assumed the issue was going to be present in 8.0.2 too - fixing 5.5.3 in node_modules made it go away. Oh well, I guess it doesn't hurt to have this keyword 🤷‍♂

Update

Actually, I think I may have got to the bottom of it - there is Queries defined (but not exported) in dom-testing-library/@testing-library/dom, but it wasn't present in the version we have at work (https://unpkg.com/[email protected]/typings/get-queries-for-element.d.ts). For some reason, this was causing an issue. But once we had updated to the new RTL (which pulled in a newer DTL), this issue went away. Now I'm not 100% sure whether without my change it's the Queries defined in DTL that's exported or RTL, I would think that with the export keyword, it's the RTL one which might be better? 🤷‍♂ I'll try to spend some time later to figure out if perhaps we don't need these interfaces at all and whether they can be taken from DTL instead.

Update 2

Seems like you came to the same conclusion in #331 (review) :)

@NMinhNguyen NMinhNguyen deleted the pr/export-queries-interface branch June 25, 2019 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export Queries interface
2 participants