-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Can't return an ElementFinder from an async function #3831
Comments
Thanks for investigating. Historically, we removed the |
Just to add some clarification for anyone reading this: https://github.com/angular/protractor/blob/master/lib/element.ts#L808 shows that the Every If a "standard" However, if the promise implicitly returned by the I've submitted a PR with what I believe is the correct typing for the I submitted this PR on the basis that it would be incorrect to leave the I should note that it may be possible to have a subclass of |
@juliemr I think this issue can be closed as the PR was merged :) |
@juliemr @massimocode This PR #3835 did not fix the issue. Typescript still complains "An async function or method must have a valid awaitable return type." |
@awaisraad the PR did fix it at the time making the the |
@Fuun347 thank you for clarifying. |
Is there any known workaround for this issue in Typescript 3.9? |
@blidblid yes the workaround is to update the types for ElementFinder in element.d.ts. |
sorry but that's not a workaround at all. How Am I supposed to remove that in a CI job where the dependencies are installed on a remote server then immediately built? Very dissapointed to see that this post is 2 years old and there is still no real fix. This is causing real issues for us updating to angular 10. |
@Roaders for now I cannot see a way to remove from protractor as I believe it would be very breaking. The only real workaround I see is not to return I cannot really also classify this as a bug as it's intended behavior. You should not be able to return a thenable and |
The ElementFinder may have a
.then
member. If it does, functions passed to the.then
member will be passed a value of typeany
. The current type annotations for this member do not accurately represent this and cause errors when using async/await.The errors can be seen by pasting the following code into a TypeScript file:
The text was updated successfully, but these errors were encountered: