-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
Bug 🐛TypeScriptgood first picka reasonable task to start getting familiar with the code basea reasonable task to start getting familiar with the code basehelp wantedIssues that are free to take by anyone interestedIssues that are free to take by anyone interested
Description
Environment:
- WebdriverIO version:
7.0.5 - Mode: WDIO Testrunner
- If WDIO Testrunner, running sync/async: async
- Node.js version:
15.6.0 - NPM version:
7.4.0 - Browser name and version: not applicable
- Platform name and version: not applicable
- Additional wdio packages used (if applicable): not applicable
Config of WebdriverIO
not applicable
Describe the bug
In version 7 of WDIO, the type definitions for browser.execute() seem to have changed but have become incorrect when using WebdriverIO.Elements as arguments. The type definitions do not model the conversion of WebdriverIO.Elements into W3C DOM Elements. Instead, inner arguments types are expected to also be the outer ones.
To Reproduce
- Setup WebdriverIO project with TypeScript as described here:
- Put this code into any file:
function foo(wdioElement: WebdriverIO.Element) {
await browser.execute((domElement: Element) => {
domElement.addEventListener("click", () => console.log("whatever"));
}, wdioElement);
}- Run TypeScript to check for errors
Expected behavior
TS should not show errors since at runtime WebdriverIO.Element is landing in the browser-side as a DOM Element. Note, that stripping the Element type from domElement: Element will move the error to the domElement.addEventListener(...) line.
Log
system-tests/src/safariClickHack.ts:35:8 - error TS2345: Argument of type 'WebdriverIO.Element' is not assignable to parameter of type 'Element'.
Type 'Element' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 120 more.
35 }, element);
~~~~~~~
Additional context
Used TypeScript version 4.1.5.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Bug 🐛TypeScriptgood first picka reasonable task to start getting familiar with the code basea reasonable task to start getting familiar with the code basehelp wantedIssues that are free to take by anyone interestedIssues that are free to take by anyone interested