I'm trying to set up testing on my TypeScript SPA using webdriver.io. I set up wdio but could not compile the typescript because of various type conflicts caused by new types introduced by wdio.
For example, wdio introduces $ which conflicts with $ in jQuery:
node_modules/@types/jquery/misc.d.ts:6536:15 - error TS2451: Cannot redeclare block-scoped variable '$'.
6536 declare const $: JQueryStatic;
~
node_modules/@wdio/sync/webdriverio.d.ts:38:18
38 declare function $(selector: string | Function): WebdriverIO.Element;
~
'$' was also declared here.
Node also introduces various conflicts:
node_modules/@types/node/index.d.ts:66:11 - error TS2300: Duplicate identifier 'IteratorResult'.
66 interface IteratorResult<T> { }
~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6
41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
~~~~~~~~~~~~~~
'IteratorResult' was also declared here.
and, more subtley, the Node types change the return type of a setTimeout
wwwroot/app/shared/lib/decorators/debounce.ts:36:17 - error TS2345: Argument of type 'Timer' is not assignable to parameter of type 'number'.
36 setTimeout(method.bind(this, ...args), milliseconds)
I definitely want to use TypeScript to build both the tests and the app, as I want to leverage the app types in the tests. I assume this means I need to build them in tandem.
Do any workarounds for this exist?