Skip to content

Commit 257fe15

Browse files
Update custom_matchers new interface
1 parent 117f04d commit 257fe15

File tree

1 file changed

+3
-15
lines changed
  • exercises/03.assertions/01.solution.custom-matchers

1 file changed

+3
-15
lines changed

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,13 @@ 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()`.
46-
47-
<callout-info>Since Vitest 3.2, you can extend the `Matchers` interface to have type-safe assertions in `expect.extend`, `expect().*` and `expect.*` methods at the same time.</callout-info>
41+
This is the interface from `vitest` that I extend using module augmentation:
4842

49-
```diff ts filename=vitest.setup.ts add=3 remove=2,3 highlight=3
50-
declare module 'vitest' {
51-
- interface Assertion<T = any> extends CustomMatchers<T> {}
52-
- interface MatchersDeclaration extends CustomMatchers {}
53-
+ interface Matchers<T> extends CustomMatchers {}
54-
}
55-
```
43+
- `Matchers<T>`, which controls the matchers returned by calling `expect()` and annotates the matcher declarations passed to `expect.extend()`.
5644

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

0 commit comments

Comments
 (0)