diff --git a/website/docs/en/api/runtime-api/test-api/expect.mdx b/website/docs/en/api/runtime-api/test-api/expect.mdx index 28c39bccb..3bdab92b8 100644 --- a/website/docs/en/api/runtime-api/test-api/expect.mdx +++ b/website/docs/en/api/runtime-api/test-api/expect.mdx @@ -342,3 +342,13 @@ expect.extend({ expect(10).toBeDivisibleBy(2); ``` + +If you want to add TypeScript typings for your custom matchers, you can extend the `Assertion` interface in the `@rstest/core` module: + +```ts +declare module '@rstest/core' { + interface Assertion { + toBeDivisibleBy(argument: number): void; + } +} +``` diff --git a/website/docs/zh/api/runtime-api/test-api/expect.mdx b/website/docs/zh/api/runtime-api/test-api/expect.mdx index dca96566a..588d8a810 100644 --- a/website/docs/zh/api/runtime-api/test-api/expect.mdx +++ b/website/docs/zh/api/runtime-api/test-api/expect.mdx @@ -341,3 +341,13 @@ expect.extend({ expect(10).toBeDivisibleBy(2); ``` + +如果你想为自定义匹配器添加 TypeScript 类型定义,可以扩展 `@rstest/core` 模块中的 `Assertion` 接口声明: + +```ts +declare module '@rstest/core' { + interface Assertion { + toBeDivisibleBy(argument: number): void; + } +} +```