jest-extended icon indicating copy to clipboard operation
jest-extended copied to clipboard

fix: remove disguised type assertion

Open igorwessel opened this issue 3 years ago • 1 comments

What

All the matchers that were using generic, weren't taking advantage of the full potential of typescript.

Why

The vast majority of matchers related to Array, Object and Satisfy. Doesn't take advantage of typescript's potential to be able to infer types, and because of that, the object matchers that were related to the object's key allowed passing other keys

without refactor: example_without_refactor

with refactor: example_with_refactor

I did this refactoring on all Object, Array and Satisfy matchers. It was just those who used generics.

Notes

Housekeeping

  • [x] Unit tests
  • [x] Documentation is up to date
  • [x] No additional lint warnings
  • [x] Typescript definitions are added/updated where relevant

igorwessel avatar Jan 23 '22 14:01 igorwessel

I realized it's not a good idea to do this due to the .not operators.

igorwessel avatar Jan 25 '22 11:01 igorwessel