Skip to content

Support spread parameters for extensions [in types] #6350

@wheresrhys

Description

@wheresrhys

Clear and concise description of the problem

I'm porting fetch-mock-jest to a new version for vitest.

In order to create an API that blends jest's mock function assertions and fetch-mock's filtering API I used the following signature:

toHaveLastFetched: ({ fetchMock }: { fetchMock: FetchMock }, filter: CallHistoryFilter, options: RouteConfig): SyncExpectationResult => {

Which in turn relies on jest's use of spread parameters:

However vitest does not use spread, forcing me to put all my options in a single object, rather than the previous API design which was far more idiomatic fro fetch-mock users.

Suggested solution

Implement the same API as jest.

I wonder if you are already doing this internally, only the types do not reflect it? (I have some tests which I would expect to fail, as I am passing additional parameters into my RawMatcherFn instances, however the tests pass; it is only the type checking that does not)

Alternative

No response

Additional context

@fetch-mock/vitest codebase https://github.com/wheresrhys/fetch-mock/pull/781/files#diff-9a85644e0fd893bb1f83cfadf2bac0296379d4fb55a14d81d1f6699d0e13364fR34

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions