Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not assignable to type MockArrayResponse #401

Open
matttk opened this issue Nov 8, 2024 · 1 comment
Open

Not assignable to type MockArrayResponse #401

matttk opened this issue Nov 8, 2024 · 1 comment

Comments

@matttk
Copy link

matttk commented Nov 8, 2024

I updated to v2.1.0 today and now I am getting multiple compile errors with "not assignable to type MockArrayResponse". I see from the releases page that MockResponse types have been added.

The problem is that I have some helper functions that return some responses.

e.g.

function getResponse(config: AxiosRequestConfig) {
  // blah blah
  
  return [
    200,
    {
      // etc.
    }
  ];
}

If I simply add : [number, { [key: string]: unknown }] as a return type for the above function, the compile error goes away. Without it, typescript automatically assumes the type is Array<number | { /* object description here */ }>, which is not accepted.

If I just copy and paste MockArrayResponse into the file, everything compiles just fine. Is there any reason not to export this type?

@matttk
Copy link
Author

matttk commented Nov 8, 2024

Hmmm... I fixed the version to 2.0.0 and still have the issue, but I was also updating TypeScript to 5.6.3. When I revert that back to 5.6.2, it works fine, so I'm assuming the problem is actually due to some TS changes.

Nevertheless, having an response type would help here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant