Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions types/expect-webdriverio.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
type SnapshotResult = import('@vitest/snapshot').SnapshotResult
type SnapshotUpdateState = import('@vitest/snapshot').SnapshotUpdateState

type ChainablePromiseElement = import('webdriverio').ChainablePromiseElement
type ChainablePromiseArray = import('webdriverio').ChainablePromiseArray
type ChainablePromiseElement = ReturnType<WebdriverIO.Browser['$']>

Check failure on line 11 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (22.x)

Property '$' does not exist on type 'Browser'.

Check failure on line 11 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (20.x)

Property '$' does not exist on type 'Browser'.

Check failure on line 11 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (24.x)

Property '$' does not exist on type 'Browser'.
type ChainablePromiseArray = ReturnType<WebdriverIO.Browser['$$']>

Check failure on line 12 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (22.x)

Property '$$' does not exist on type 'Browser'.

Check failure on line 12 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (20.x)

Property '$$' does not exist on type 'Browser'.

Check failure on line 12 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (24.x)

Property '$$' does not exist on type 'Browser'.
Comment on lines +11 to +12
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 ReturnType on overloaded methods picks only the last overload

TypeScript's ReturnType resolves to the return type of the last overload signature when the target is an overloaded function. WebdriverIO.Browser['$'] and ['$$'] are typically overloaded (accepting string, Function, Element, etc.), so if any overload other than the last carries a different return type the alias would silently diverge from its intended meaning. In practice all overloads of $/$$ currently return ChainablePromiseElement/ChainablePromiseArray respectively, so this is not a bug today — but it's a subtle coupling to the ordering of WebdriverIO's internal overload declarations that could break silently if upstream changes them. A comment documenting this assumption would help future maintainers.


type ExpectLibAsymmetricMatchers = import('expect').AsymmetricMatchers
type ExpectLibAsymmetricMatcher<T> = import('expect').AsymmetricMatcher<T>
Expand Down Expand Up @@ -55,7 +55,7 @@
type ElementOrArrayLike = ElementLike | ElementArrayLike
type ElementLike = WebdriverIO.Element | ChainablePromiseElement
type ElementArrayLike = WebdriverIO.ElementArray | ChainablePromiseArray | WebdriverIO.Element[]
type MockPromise = Promise<WebdriverIO.Mock>

Check failure on line 58 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (22.x)

Namespace 'global.WebdriverIO' has no exported member 'Mock'.

Check failure on line 58 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (20.x)

Namespace 'global.WebdriverIO' has no exported member 'Mock'.

Check failure on line 58 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (24.x)

Namespace 'global.WebdriverIO' has no exported member 'Mock'.

/**
* Type helpers allowing to use the function when the expect(actual: T) is of the expected type T.
Expand All @@ -67,7 +67,7 @@
/**
* Same as the other but because of Jasmine and it's expectAsync typing which does not force T to be a promise, then we need to account for `WebdriverIO.Mock
*/
type FnWhenMock<ActualT, Fn> = ActualT extends MockPromise | WebdriverIO.Mock ? Fn : never

Check failure on line 70 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (22.x)

Namespace 'global.WebdriverIO' has no exported member 'Mock'.

Check failure on line 70 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (20.x)

Namespace 'global.WebdriverIO' has no exported member 'Mock'.

Check failure on line 70 in types/expect-webdriverio.d.ts

View workflow job for this annotation

GitHub Actions / linux (24.x)

Namespace 'global.WebdriverIO' has no exported member 'Mock'.

/**
* Matchers dedicated to Wdio Browser.
Expand Down
Loading