Improve async handling in generated code#18783
Improve async handling in generated code#18783apeeters wants to merge 2 commits intoangular:masterfrom
Conversation
f03b493 to
a529bcc
Compare
|
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. |
alan-agius4
left a comment
There was a problem hiding this comment.
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.
| 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!'); |
There was a problem hiding this comment.
The outer await should not be needed here and in the other tests.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>;Method returning Promise should be async Rationale: https://palantir.github.io/tslint/rules/promise-function-async/
Avoid floating promises Rationale: https://palantir.github.io/tslint/rules/no-floating-promises/
Fixed these remarks and rebased the PR. |
|
Thank you for the contribution. This change has, however, been superseded by #18951. This will be available in the upcoming version 11. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR fixes two tslint errors in generated projects: