webdriverio-community / wdio-vscode-service

A service to test VSCode extensions from end to end using WebdriverIO

Home Page:https://webdriverio-community.github.io/wdio-vscode-service/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Types for custom commands added by wdio-vscode-service

openscript opened this issue · comments

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
	}
}

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

@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.

That works for me too.

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

That's the project: opral/monorepo#1795

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.

Any luck @openscript? I saw opral/monorepo#1795 was merged. 🎉