Skip to content

Not assignable to type MockArrayResponse #401

@matttk

Description

@matttk

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions