testing-library / webdriverio-testing-library

🕷️ Simple and complete WebdriverIO DOM testing utilities that encourage good testing practices.
17 stars 14 forks source link

fix: typescript compilation when checking libs #32

Closed olivierwilkinson closed 3 years ago

olivierwilkinson commented 3 years ago

closes #31

When the skipLibCheck Typescript compiler option is set to false compilation fails. This is due to the global WebdriverIO.Element interface being extended with ElementBase: the compiler complains that the types of $, execute and executeAsync are not identical to those found in the webdriverio package.

To fix the compilation the WebdriverIO.Element interface either needs to be extended with identical types as those used in the webdriverio package or we stop extending it with ElementBase entirely.

The first option is not realistic as at build time we don't know which version of the webdriverio package the end user will have installed. We can however stop extending the interface: WebdriverIO.Element is only extended with ElementBase to allow an element to be passed to the within method internally, if instead we coerce the WebdriverIO.Element to be an ElementBase we no longer need to extend the interface.

This does not cause any loss in type safety either as we were effectively coercing the type to be the same as ElementBase when we extended the WebdriverIO.Element interface anyways.

Change the test tsconfigs to have skipLibCheck set to false so that the typecheck script catches these types of bugs in future.

github-actions[bot] commented 3 years ago

:tada: This PR is included in version 3.0.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket: