Skip to content

Commit 568f8d4

Browse files
authored
fix(types): ChainablePromiseArray and ChainablePromiseElement resolved to any (#1872)
* Fix `ChainablePromiseArray` and `ChainablePromiseElement` resolve to any * Bring back lost command
1 parent 1385190 commit 568f8d4

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

jasmine.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
/// <reference types="expect-webdriverio/types/expect-webdriverio"/>
1+
/// <reference types="./types/expect-webdriverio.d.ts"/>
22

33
declare namespace jasmine {
4-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5-
interface AsyncMatchers<T, U> extends ExpectWebdriverIO.Matchers<Promise<void>, T> {}
4+
interface AsyncMatchers<T, _U> extends ExpectWebdriverIO.Matchers<Promise<void>, T> {}
65
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@
4646
"clean:build": "rimraf ./lib",
4747
"clean:tests": "rimraf test-types/**/node_modules && rimraf test-types/**/dist",
4848
"compile": "tsc --build tsconfig.build.json",
49+
"tsc:root-types": "tsc jasmine.d.ts jest.d.ts",
4950
"test": "run-s test:*",
5051
"test:lint": "eslint .",
5152
"test:unit": "vitest --run",
52-
"test:types": "node test-types/copy && npm run ts && npm run clean:tests",
53+
"test:types": "node test-types/copy && npm run ts && npm run clean:tests && npm run tsc:root-types",
5354
"ts": "run-s ts:*",
5455
"ts:default": "cd test-types/default && tsc -p ./tsconfig.json --incremental",
5556
"ts:jest": "cd test-types/jest && tsc -p ./tsconfig.json --incremental",

src/matchers/element/toHaveAttribute.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function conditionAttrAndValue(el: WebdriverIO.Element, attribute: string,
2626
return compareText(attr, value, options)
2727
}
2828

29-
export async function toHaveAttributeAndValue(received: ChainablePromiseElement, attribute: string, value: string | RegExp | ExpectWebdriverIO.PartialMatcher, options: ExpectWebdriverIO.StringOptions = DEFAULT_OPTIONS) {
29+
export async function toHaveAttributeAndValue(received: WdioElementMaybePromise, attribute: string, value: string | RegExp | ExpectWebdriverIO.PartialMatcher, options: ExpectWebdriverIO.StringOptions = DEFAULT_OPTIONS) {
3030
const isNot = this.isNot
3131
const { expectation = 'attribute', verb = 'have' } = this
3232

@@ -49,11 +49,11 @@ export async function toHaveAttributeAndValue(received: ChainablePromiseElement,
4949
} as ExpectWebdriverIO.AssertionResult
5050
}
5151

52-
async function toHaveAttributeFn(received: ChainablePromiseElement | WebdriverIO.Element, attribute: string) {
52+
async function toHaveAttributeFn(received: WdioElementMaybePromise, attribute: string) {
5353
const isNot = this.isNot
5454
const { expectation = 'attribute', verb = 'have' } = this
5555

56-
let el = await received
56+
let el = await received?.getElement()
5757

5858
const pass = await waitUntil(async () => {
5959
const result = await executeCommand.call(this, el, conditionAttr, {}, [attribute])

types/standalone.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference types="./expect-webdriverio.js"/>
22

3-
type ChainablePromiseElement = import('webdriverio').ChainablePromiseElement<WebdriverIO.Element>
4-
type ChainablePromiseArray = import('webdriverio').ChainablePromiseArray<WebdriverIO.Element>
3+
type ChainablePromiseElement = import('webdriverio').ChainablePromiseElement
4+
type ChainablePromiseArray = import('webdriverio').ChainablePromiseArray
55

66
declare namespace ExpectWebdriverIO {
77
interface Matchers<R extends void | Promise<void>, T> extends Readonly<import('expect').Matchers<R>> {

0 commit comments

Comments
 (0)