Skip to content

Commit 3a761ae

Browse files
docs(custom_matchers): clarify match interfaces difference (#9)
Co-authored-by: Artem Zakharchenko <[email protected]>
1 parent 765ea92 commit 3a761ae

File tree

1 file changed

+2
-6
lines changed
  • exercises/03.assertions/01.solution.custom-matchers

1 file changed

+2
-6
lines changed

exercises/03.assertions/01.solution.custom-matchers/README.mdx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,11 @@ interface CustomMatchers<MatcherResult = any> {
3434
}
3535

3636
declare module 'vitest' {
37-
interface Assertion<T = any> extends CustomMatchers<T> {}
38-
interface MatchersDeclaration extends CustomMatchers {}
37+
interface Matchers<T> extends CustomMatchers<T> {}
3938
}
4039
```
4140

42-
There are two interfaces from `vitest` that I extend using module augmentgation:
43-
44-
- `Assertion<T>`, which controls the matchers returned by calling `expect()`;
45-
- `MatchersDeclaration`, which annotates the matcher declarations passed to `expect.extend()`.
41+
Here, I'm augmenting the `Matchers` type from `vitest` with my custom `CustomMatchers` type. By doing so, I'm extending the type definitions for the `expect()` function as well as the argument type of `expect.extend()` for later.
4642

4743
This is enough for the `.toMatchSchema()` custom matcher to be recognized by TypeScript:
4844

0 commit comments

Comments
 (0)