Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace 'global.WebDriver' has no exported member 'Client' after updating WDIO to v7 #229

Open
DrewciferB opened this issue Feb 9, 2022 · 8 comments

Comments

@DrewciferB
Copy link

Hi there, I'm getting the following error on compile after updating WDIO to v7. Everything works fine under v6.

node_modules/wdio-intercept-service/types/wdio-intercept-service.d.ts:60:59 - error TS2694: Namespace 'global.WebDriver' has no exported member 'Client'.
60 type AsyncSync<T> = WebdriverIO.Browser extends WebDriver.Client

It seems that intercept service is defining a type based on an extension of Webdriver.Client, but the global namespace no longer exports Client as an interface in WDIO v7? I admit I'm quite out of my depth here, so apologies if I've missed something basic.

I have Intercept v4.2.1 specified in package.json: "wdio-intercept-service": "^4.2.1",

Here are my tsconfig.json types "types": ["node", "webdriverio/sync", "@wdio/mocha-framework", "wdio-intercept-service"]

I notice that the types changed in v7 from @wdio/sync to webdriverio/sync, not sure if that has anything to do with this but the error seems to be happening around code that is concerned with detecting sync mode, so I thought it might be relevant (from wdio-intercept-service/types/wdio-intercept-service.d.ts):

/**
 * Convert T to T or Promise<T> depending if `@wdio/sync` is being used or not.
 */
type AsyncSync<T> = WebdriverIO.Browser extends WebDriver.Client
  ? T
  : Promise<T>;

Even installing a brand new v7 webdriver project into a blank folder and then adding the intercept service still triggered this error, and it also occurs regardless of whether @wdio/sync is installed or not. Any help much appreciated 👍

@tehhowch
Copy link
Contributor

tehhowch commented Feb 9, 2022

PRs welcomed.
Note that the types need to support at minimum wdio 6 and 7, in both sync and async modes, as these are all official versions of WebdriverIO.

As you have experienced, I don't believe this is currently done correctly.

@christian-bromann is best positioned to offer insight on how services that add custom commands can provide accurate types for all WDIO versions that have official support.

Until then, you will probably need to modify the types yourself locally. IIRC there are other issues in this repo that have identified issues with this library and typescript.

@DrewciferB
Copy link
Author

DrewciferB commented Feb 9, 2022

@tehhowch I don't feel I really understand this anywhere near well enough to contribute, but making the following change at line 60 of wdio-intercept-service/types/wdio-intercept-service.d.ts removes the problem and allows the project to compile. I tried it in WDIO v6 and v7, in both sync and async mode, and it seems to work. The problem is that I don't understand what's actually going on here, so I don't understand the ramifications of this suggestion (if any):

- type AsyncSync<T> = WebdriverIO.Browser extends WebDriver.Client
+ type AsyncSync<T> = WebdriverIO.Browser extends WebDriver.Capabilities

After making the change, intercept service also seemed to be working normally in all configurations, returning events etc.

@wyhmichael
Copy link

wyhmichael commented May 25, 2022

@tehhowch @christian-bromann any suggestions?

@franklinkim
Copy link

@DrewciferB can confirm, that patching that line works. Should this be fixed?

@christian-bromann
Copy link
Contributor

@franklinkim I recommend upgrading to v8 where this issue should not persist anymore. Feel free to raise a PR with a fix to the v7 branch in webdriverio/webdriverio.

@TheRealCleany
Copy link

@christian-bromann I've upgraded to v8, but it still persists.

@Grobouls
Copy link

Yes and it is quite annoying with typescript :/

@derenandrii
Copy link

facing the same issue in wdio v8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants