Skip to content

Improve async handling in generated code#18783

Closed
apeeters wants to merge 2 commits intoangular:masterfrom
apeeters:fix_async
Closed

Improve async handling in generated code#18783
apeeters wants to merge 2 commits intoangular:masterfrom
apeeters:fix_async

Conversation

@apeeters
Copy link
Copy Markdown

This PR fixes two tslint errors in generated projects:

  • Promise returning method should be async
  • Avoid floating promises

@apeeters apeeters force-pushed the fix_async branch 3 times, most recently from f03b493 to a529bcc Compare September 14, 2020 13:20
@alan-agius4
Copy link
Copy Markdown
Collaborator

alan-agius4 commented Sep 14, 2020

The “floating” promises are intended. See: #17652 (comment)

@apeeters
Copy link
Copy Markdown
Author

The “floating” promises are intended. See: #17652 (comment)

Unfortunately the PR mentioned in that comment (#15472) is closed. I can't find any documentation or plan on how this will be fixed/resolved.

Copy link
Copy Markdown
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

We had a chat around this yesterday during our team meeting and doing this change shouldn't break Protractor. Therefore this should be good to go after

  • Update the commit message scopes to @schematics/angular
  • Dropping Jasmine bump commit since this seems redundant.

@alan-agius4 alan-agius4 added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Sep 15, 2020
expect(page.getTitleText()).toEqual('integration-project app is running!');
it('should display welcome message', async () => {
await page.navigateTo();
await expect(await page.getTitleText()).toEqual('integration-project app is running!');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The outer await should not be needed here and in the other tests.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The tsconfig.json.template file in packages/schematics/angular/e2e/files specifies jasminewd2 in types. The method signatures in these type definitions return Promises. So I believe this change is needed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It returns a promise because it's a generic, therefore if you await the return type is no longer a promise.

declare function expect<T>(actual: ArrayLike<T>): jasmine.ArrayLikeMatchers<T>;

@apeeters
Copy link
Copy Markdown
Author

  • Update the commit message scopes to @schematics/angular
  • Dropping Jasmine bump commit since this seems redundant.

Fixed these remarks and rebased the PR.

@clydin
Copy link
Copy Markdown
Member

clydin commented Oct 6, 2020

Thank you for the contribution. This change has, however, been superseded by #18951. This will be available in the upcoming version 11.

@clydin clydin closed this Oct 6, 2020
@clydin clydin removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Oct 6, 2020
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants