Description
Describe the feature you'd like:
Accurate and timely TypeScript types.
Currently types are manually maintained in the @types/
project so they are only updated after the fact and are prone to human error and implementation drift.
Suggested implementation:
Convert @testing-library/dom
to TypeScript.
Describe alternatives you've considered:
The main alternative is to leave things the way they are. Unfortunately this leaves types manually updated after the fact. This is slow, depend on third-parties (Microsoft), and is error prone.
- 10+ days after TL update without updated types [@testing-library/dom] update to v7 DefinitelyTyped/DefinitelyTyped#43102
- Requests for updated types
- Reports of incorrect types
- [TypeScript] missing
ignore
option inByText
queries #407 - Options type missing in prettyDOM function #308
- Bound functions for find* queries throw error in typescript when
waitForElementOptions
argument is supplied. #291 - Typings for event functions requires HTMLElement, but querySelector (et. al) returns Element #149
- queryByRole types aren't aligned to implementation #142
- Types for queryByTestId not correct #135
- Matcher import path is broken in get-queries-for-element typings file #42
- [TypeScript] missing
I'm sure there are other issues filed on the DefinitelyTyped repo.
Another alternative is to require DefinitelyTyped types as part of general contributions to this project. This would be a big increase to the barrier of entry as contributors would have to know how to write types and update DefinitelyTyped.
Teachability, Documentation, Adoption, Migration Strategy:
I'd look at doing a multi-stage conversion
- Initial proof of concept with one or two files to validate the approach and tooling.
- The
src
files - Updated contributing guide with guidance on types
- The
tests
files (this could be delayed until a future date) - Update testing-library.com documentation to display the latest types (optional but if they exists they might as well be used)
TypeScript does add some additional complexity in tooling and would increase the barrier of entry for contributors. This is also an opportunity to to create a simple and supportive implementation that people less familiar with TypeScript and contribute to. It would be important to create some good contributing guides on working with types (or identify and recommend some good third-party guides).
Potentially there would be bugs uncovered and fixed in the codebase with the conversion.