enzymejs / enzyme-matchers

Jasmine/Jest assertions for enzyme
MIT License
892 stars 116 forks source link

Matchers incompatible with @types/jest 24.0.20 #318

Closed mockdeep closed 4 years ago

mockdeep commented 4 years ago

Not sure how to resolve this, but it looks like upgrading @types/jest from 24.0.19 to 24.0.20 breaks compatibility with the jest-enzyme types. Seems like it can be tricky to maintain type compatibility across libraries with issues such as this.

node_modules/@types/jest/index.d.ts:639:15 - error TS2428: All declarations of 'Matchers' must have identical type parameters.

639     interface Matchers<R, T> {
                  ~~~~~~~~

node_modules/jest-enzyme/lib/index.d.ts:7:15 - error TS2428: All declarations of 'Matchers' must have identical type parameters.

7     interface Matchers<R> {
blainekasten commented 4 years ago

ugh. interfaces are globally scoped.. so dumb. we should just change to use type internally. I think that should fix it.

Could you test by making this change at node_modules/jest-enzyme/lib/index.d.ts:7:15 in your codebase?

just change it to type Matchers<R> = {

vkrol commented 4 years ago

@blainekasten It doesn't work.

node_modules/@types/jest/index.d.ts:639:15 - error TS2300: Duplicate identifier 'Matchers'.

639     interface Matchers<R, T> {
                  ~~~~~~~~

  node_modules/jest-enzyme/lib/index.d.ts:7:10
    7     type Matchers<R> = {
               ~~~~~~~~
    'Matchers' was also declared here.

node_modules/jest-enzyme/lib/index.d.ts:7:10 - error TS2300: Duplicate identifier 'Matchers'.

7     type Matchers<R> = {
           ~~~~~~~~

  node_modules/@types/jest/index.d.ts:639:15
    639     interface Matchers<R, T> {
                      ~~~~~~~~
    'Matchers' was also declared here.

I thank that we need to change interface Matchers<R> to interface Matchers<R, T> in jest-enzyme.

blainekasten commented 4 years ago

@vkrol did you test that locally to see it fix it? It just seems weird that typescript thinks they are the same

vkrol commented 4 years ago

@blainekasten

did you test that locally to see it fix it?

Yes.

It just seems weird that typescript thinks they are the same

That's okay, because they're in the same namespace jest.