jefflau / jest-fetch-mock

Jest mock for fetch
MIT License
883 stars 116 forks source link

Typescript compiler error caused by FetchMock #108

Closed haggs closed 5 years ago

haggs commented 5 years ago

I'm on jest-fetch-mock 2.1.0, running into this compiler error in my typescript project, when I try to build.

Type error: Generic type 'MockInstance<T, Y>' requires 2 type argument(s).  TS2314

    17 | }
    18 | 
  > 19 | export interface FetchMock extends jest.MockInstance<any> {
       |                                    ^
    20 |     (input?: string | Request, init?: RequestInit): Promise<Response>;
    21 | 
    22 |     mockResponse(body: BodyOrFunction, init?: MockParams): FetchMock;

I believe line 19 should be:

export interface FetchMock extends jest.MockInstance<any, any> {
haggs commented 5 years ago

Ah wait, I didn't realize MockInstance was from jest. Probably something to do with my version of jest in my project...

haggs commented 5 years ago

I decided to leave this open because it will be an issue if you have an updated version of @types/jest. I experienced this error with @types/jest@23.3.14 and it looks like jest-fetch-mock is using 23.3.10.

kevcenteno commented 5 years ago

Fixed in #106