-
Notifications
You must be signed in to change notification settings - Fork 12k
fix(@angular/cli): Do not use floating promises, we can resolve these… #17652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { browser, by, element } from 'protractor'; | ||
|
||
export class AppPage { | ||
navigateTo(): Promise<unknown> { | ||
async navigateTo(): Promise<unknown> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, you can also use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, no reason for |
||
return browser.get(browser.baseUrl) as Promise<unknown>; | ||
} | ||
|
||
getTitleText(): Promise<string> { | ||
async getTitleText(): Promise<string> { | ||
return element(by.css('<%= rootSelector %> .content span')).getText() as Promise<string>; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any point in using
async
if you are notawait
ing the promise?I would expect either
async () => { await TestBed... }
or() => { return TestBed... }
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd probably go with
await
to make it more explicit that it is an asynchronous operation and also slightly simplify future user additions (either before or after the call).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think async shouldn't only be used when awaiting, returning the promise also showcases asynchronous behavior.