[@types/testing-library__jest-dom] hijacks Jest's Matchers interface
#64858
Unanswered
vhenzl
asked this question in
Issues with a @types package
Replies: 2 comments 1 reply
-
|
Thanks for the discussion about "testing-library__jest-dom", some useful links for everyone: Pinging the DT module owners: @gnapse, @jgoz, @smacpherson64, @AndrewLeedham. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
We also noticed this, and created a PR with a fix: #66247 Just removing the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The
Matchersinterface in@types/testing-library__jest-domcurrently extendsRecord<string, any>interface (viaTestingLibraryMatchersinterface): https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/testing-library__jest-dom/matchers.d.ts#L1This makes the
Matchersinterface unsafe. Because ofRecord, any unknown property or function is automaticallyany.So, if I make a typo like
expect('a value').toBee()(instead oftoBe()) or use a non-existent matcherexpect('a value').toBeXYZ(), TypeScript can't point it out, and I learn about the problem only in runtime when running the test.There seems not to be any good reason for extending from
Record; it should be removed from the type.Beta Was this translation helpful? Give feedback.
All reactions