Skip to content

Abstract methods should not allow async modifier #28516

Closed
@aleph-naught2tog

Description

@aleph-naught2tog

This had already been discussed here which was a different issue that was concluded to be intended behaviour, but that abstract methods allowing async was not intended.

TypeScript Version: Version 3.2.0-dev.20181113

Search Terms:
abstract async, async

Code

// assuming `--lib es2015` is passed to the compiler
abstract class ShouldFailClass {
  async abstract someMethod(): Promise<number>; // This should error, but doesn't
}

Expected behavior:
Abstract methods should not allow an async modifier in the same way an interface and other type parameters don't allow them.

Actual behavior:
Abstract methods do not error with an async modifier attached; interface methods do.

Playground Link: Both of these should error, not just the second on, as discussed in the earlier linked issue. Reproduced here

Related Issues:
Originally discussed in the comments in here, where the consensus was that the behavior was intended for that case, but that async abstract should not be allowed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions