Skip to content

[📖 Docs]: Improve TypeScript documentation for extending expect #11960

@MrGVSV

Description

@MrGVSV

Pre-check

  • I know I can edit the docs but prefer to file this issue

Describe the improvement

Unclear documentation

Description of the improvement / report

Currently, the docs for extending WDIO's expect with a custom matcher only use JavaScript as an example.

While following these docs does work, TypeScript users will run into compiler errors. This is because the normal method for extending the expect type does not seem to have any effect on the expect from expect.webdriverio:

declare module 'expect' {
  interface AsymmetricMatchers {
    toBeWithinRange(floor: number, ceiling: number): void;
  }
  interface Matchers<R> {
    toBeWithinRange(floor: number, ceiling: number): R;
  }
}
error TS2339: Property 'toBeWithinRange' does not exist on type 'Matchers<void, number>'

It would be nice if the docs included a snippet for TypeScript users demonstrating how to properly extend the type for expect when extending it with custom matchers.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions