Skip to content

Disallows async abstract method declarations #28517

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

Closed

Conversation

aleph-naught2tog
Copy link

@aleph-naught2tog aleph-naught2tog commented Nov 14, 2018

Since we do not allow async as a modifier on type members such as in an interface, it was decided that it should also not be allowed on abstract methods.

Submitting a PR for this had been discussed on the original issue (which was then concluded to not be an actual bug, whereas this scenario is). This PR addresses the issue discussed in the comments here.

Edit by @DanielRosenwasser: Fixes #28516

Since we do not allow `async` as a modifier on type members such as in an interface, it was decided that it should also not be allowed on abstract methods.

Fixes microsoft#28516.
@@ -0,0 +1,4 @@
// @lib: es2015
Copy link
Member

Choose a reason for hiding this comment

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

@rbuckton is // @lib: es2015 the right thing or is there a leaner way to run this?

@@ -28342,6 +28342,9 @@ namespace ts {
if (flags & ModifierFlags.Private) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract");
}
if (flags & ModifierFlags.Async) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract");
Copy link
Member

Choose a reason for hiding this comment

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

I think the error spans that we give are on the wrong keyword in all of these places. For example, the problem isn't that you've declared the thing as abstract, it's that it makes no sense to mark an abstract member as async.

But I guess that's not your problem. It might be suitable for a follow-up PR if it's not too disruptive.

Copy link
Author

Choose a reason for hiding this comment

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

Do you mean the error should appear on async instead? I agree that's not really in the scope of this PR but that is one I would be happy to tackle as an experiment to evaluate whether it is too disruptive.

@DanielRosenwasser
Copy link
Member

I'm not sure why you're getting a test failure; all I get on my machine is

ERROR: /home/daniel/shared/TypeScript/src/compiler/checker.ts:714:110 whitespace missing whitespace

@aleph-naught2tog
Copy link
Author

Yeah; I don't get the whitespace notice on my machine, but no failed tests or baseline issues here, either, just when I push up to CI 🤔

@aleph-naught2tog
Copy link
Author

@weswigham @DanielRosenwasser suggested I ping you about the CI failure; I'm not sure where to go next in terms of debugging it since it works on my machine, I accept the baseline, etc

@rbuckton
Copy link
Contributor

rbuckton commented Feb 7, 2019

@aleph-naught2tog: The CI appears to be failing because abstractAsync.types differs from the reference baseline. Can you ensure the latest version of that file is included?

@sandersn sandersn added the For Backlog Bug PRs that fix a backlog bug label Feb 1, 2020
@sandersn
Copy link
Member

This PR hasn't seen any activity for quite a while, so I'm going to close it to keep the number of open PRs manageable. Feel free to open a fresh PR or ask for more help here.

@sandersn sandersn closed this Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Abstract methods should not allow async modifier
4 participants