jest-matcher-deep-close-to
jest-matcher-deep-close-to copied to clipboard
Accept typed objects
Hi, I had a typescript issue using this matcher with named interface types like
interface Point {
x: number;
y: number;
}
The error is (with typescript v4.4.3):
Argument of type 'Point' is not assignable to parameter of type 'Iterable'.
Type 'Point' is not assignable to type 'IterableObject'.
Index signature for type 'string' is missing in type 'Point'.ts(2345)
If the type information is removed, everything works OK. So when I checked, I've seen there are more runtime type checks (in recursiveCheck
) so maybe the typing could be relaxed a bit to allow this scenario. Unfortunately I couldn't come up with a better solution than just allowing the exact type coming from expect(value: T)
... which I think if the user would use, it should be most of the time correct.
I hope this solution is acceptable (or somebody could improve it). Thanks.
Looks like a nice proposal ... any updates?
Should we update documentation as well?