Skip to content

Add typescript definitions #37

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 3 commits into from
May 8, 2018
Merged

Conversation

maddijoyce
Copy link
Collaborator

@maddijoyce maddijoyce commented May 8, 2018

What: Adding typescript definitions

Why: The types for some parts of the dom-testing-library are currently in use in react-testing-library. Really these should be stored alongside the appropriate code and then imported as needed.

How: Added d.ts files with definitions to match functions. Some definitions pulled from react-testing-library (thanks @alexkrolick and @InExtremaRes).

Checklist:

  • Documentation N/A
  • Tests
  • Ready to be merged
  • Added myself to contributors table

I think adding dtslint is a good first step as far as keeping the definition files tested and avoiding types issues (as per testing-library/react-testing-library#82).

The types are only compatible with TypeScript 2.8 and up, because I've used mapped types for the bindElementToQueries function. It's possible to avoid using mapped types, but it means duplication of a lot of the queries code, and I think it's better to avoid that.

If you're happy with these types, I can update the react-testing-library to use them once everything has been merged.

@maddijoyce
Copy link
Collaborator Author

Also fixed a small error in events.js.
The copy event was using a CompositionEvent not a ClipboardEvent

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.

Looks great to me! I'm going to call this good considering your our TypeScript maintainer 😉

@kentcdodds kentcdodds merged commit 56b768d into testing-library:master May 8, 2018
@kentcdodds
Copy link
Member

Thanks so much for your help! I've added you as a collaborator on the project. Please make sure that you review the other/MAINTAINING.md and CONTRIBUTING.md files (specifically the bit about the commit messages and the git hooks) and familiarize yourself with the code of conduct (we're using the contributor covenant). You might also want to watch the repo to be notified when someone files an issue/PR. Please continue to make PRs as you feel the need (you can make your branches directly on the repo rather than your fork if you want). Thanks! And welcome to the team :)

alexkrolick pushed a commit to alexkrolick/dom-testing-library that referenced this pull request Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants