Skip to content

Support vitest v3.2 Multi-Purpose Matchers Type #809

@kevbook

Description

@kevbook

Is your feature request related to a problem? Please describe.

When using the below syntax, we get TS errors.

expect.extend(jestMatchers);
  Type 'CustomMatchers<any>' is not assignable to type '{ [x: string]: RawMatcherFn<MatcherState, unknown[]> | undefined; pass?: RawMatcherFn<MatcherState, [message: string]>; fail?: RawMatcherFn<MatcherState, [message: ...]>; ... 74 more ...; toBeValidUUID?: RawMatcherFn<...>; }'.
    Types of property 'toChangeBy' are incompatible.
      Type '(checker: () => number | bigint, by?: number | bigint | undefined) => any' is not assignable to type 'RawMatcherFn<MatcherState, [checker: () => number | bigint, by?: number | bigint | undefined]>'.
        Types of parameters 'by' and 'checker' are incompatible.
          Type '() => number | bigint' is not assignable to type 'number | bigint | undefined'.ts(2345)

Describe the solution you'd like

declare module 'vitest' {
  interface Matchers<T = any> extends CustomMatchers<T> {}
}

Additional context
See release https://vitest.dev/blog/vitest-3-2.html#the-new-multi-purpose-matchers-type

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions