Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Typings error for ElementArrayFinder.filter in v5.1.0 #4058

Closed
massimocode opened this issue Feb 3, 2017 · 2 comments
Closed

Typings error for ElementArrayFinder.filter in v5.1.0 #4058

massimocode opened this issue Feb 3, 2017 · 2 comments

Comments

@massimocode
Copy link
Contributor

massimocode commented Feb 3, 2017

Looking at this commit:
995b146

This typing is incorrect:

filter(
      filterFn: (element: ElementFinder, index?: number) => boolean |
          wdpromise.Promise<boolean>): ElementArrayFinder {

It should be:

filter(
      filterFn: (element: ElementFinder, index?: number) => boolean |
          PromiseLike<boolean>): ElementArrayFinder {

The current typing breaks the following lines of code:

element.all(by.className("blah")).filter(async row => (await row.$$(".ng-binding").get(0).getText()) === "foo");

The error is:

error TS2345: Argument of type '(row: ElementFinder) => Promise<boolean>' is not assignable to parameter of type '(element: ElementFinder, index?: number) => boolean | Promise<boolean>'.
  Type 'Promise<boolean>' is not assignable to type 'boolean | Promise<boolean>'.
    Type 'Promise<boolean>' is not assignable to type 'webdriver.promise.Promise<boolean>'.

I think the same applies to the other places where it is written T | wdpromise.Promise<T>
For example ElementArrayFinder.get

@jan-molak
Copy link
Contributor

Indeed, I provided some more details in #4049

@sjelin
Copy link
Contributor

sjelin commented Feb 9, 2017

Closing as duplicate. I talk specifically about async/await issues in #4049 (comment)

@sjelin sjelin closed this as completed Feb 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants