Skip to content

[🐛 Bug]: Browser type primitive mismatches WebdriverIO.Browser global type #11055

@dbjorge

Description

@dbjorge

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

Tested in 8.15.10 (latest as of writing), introduced in 8.11.0

Node.js Version

Verified in 18.17.1, 20.5.1

Mode

Standalone Mode

Which capabilities are you using?

n/a

What happened?

As of PR #9640, WebdriverIO's typings include two copies of the Browser type, one a global type within the WebdriverIO namespace and one a type primitive exported from the module.

PR #10447 made an update to to the primitive export, but not the global namespace version.

In practice, this means that code which tries to use import type { Browser } from 'webdriverio' is incompatible with webdriverio functions that return WebdriverIO.Browser, such as remote.

What is your expected behavior?

The two copies of the type should match, ideally with one defined in terms of the other to avoid this issue in the future

How to reproduce the bug.

// repro.ts
import { type Browser, remote } from 'webdriverio';

async function main() {
    let browser: Browser; // works if using WebdriverIO.Browser instead

    browser = await remote({
        capabilities: { browserName: 'irrelevant' }
    });
}
$ npm init -y
$ npm install webdriverio@8.15.10 typescript@5.2.2
$ npx tsc --noEmit --skipLibCheck ./repro.ts

Relevant log output

repro.ts:7:5 - error TS2740: Type 'Browser' is missing the following properties from type 'Browser': sessionStatus, sessionNew, sessionEnd, sessionSubscribe, and 25 more.

7     browser = await remote({
      ~~~~~~~


Found 1 error in repro.ts:

Code of Conduct

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

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛good first picka reasonable task to start getting familiar with the code basehelp wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions