webdriverio-community / wdio-vscode-service

A service to test VSCode extensions from end to end using WebdriverIO
https://webdriverio-community.github.io/wdio-vscode-service/
MIT License
29 stars 23 forks source link

Types for custom commands added by wdio-vscode-service #95

Open openscript opened 8 months ago

openscript commented 8 months ago

How to get the types for custom commands like getWorkbench() working?

image

The following tsconfig.json is applied:

{
    "include": ["./spec/**/*.e2e.test.ts", "./wdio.conf.ts"],
    "compilerOptions": {
        "module": "ESNext",
        "types": [
            "node",
            "@wdio/globals",
            "wdio-vscode-service",
            "@wdio/mocha-framework",
            "expect-webdriverio"
        ],
        "target": "es2022",
        "moduleResolution": "node",
        "esModuleInterop": true,
        "experimentalDecorators": true
    }
}
openscript commented 8 months ago

If I add import {} from "wdio-vscode-service" where I use getWorkbench() or if I use "wdio-vscode-service/service" in the tsconfig.json types VSCode can resolve the types. Quite weird.. something with type declaration merging doesn't seem to work like it should.

I'm on VSCode:

Version: 1.84.2
Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
Date: 2023-11-09T10:50:47.800Z
Electron: 25.9.2
ElectronBuildId: 24603566
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Linux x64 6.6.3-arch1-1
christian-bromann commented 8 months ago

@openscript can you compare your setup with the one that is being created when running npm init wdio@latest ./foobar and selecting "VS Code Extension Testing"? I just bootstrapped a new project and the types were resolved as expected.

openscript commented 8 months ago

That works for me too.

Now I'm suspecting pnpm which is used in the project with the issue.

openscript commented 8 months ago

That's the project: https://github.com/inlang/monorepo/pull/1795

christian-bromann commented 8 months ago

I checked out the repo and it is indeed weird why types aren't resolved. Even if I add /// <reference types="wdio-vscode-service" /> at the top instead of import {} from "wdio-vscode-service" it works. I also tried to copy the dependency into the node_modules directory to remove the chance it could have to do with pnpm linking. The setup looks fine to me.

seanpoulter commented 4 months ago

Any luck @openscript? I saw https://github.com/opral/monorepo/pull/1795 was merged. :tada: