Skip to content

Does async set the return type in reflect.metadata to promise? #8351

Description

Hey TS - Heroes :-)

I've got a small question. Is the async keyword intended to set the correct return type when using decorators? I'd expect such a thing:

classFoo{
@AnyDecorator()publicasyncfoobar(){}}

this should decorate the function foobar with the return type Promise.

Actually it produces:

classFoo{foobar(){return__awaiter(this,void0,void0,function*(){});}}__decorate([AnyDecorator(),__metadata('design:type',Function),__metadata('design:paramtypes',[]),__metadata('design:returntype',void0)],Foo.prototype,"foobar",null);

I'd expect the return type to be Promise like:

classFoo{foobar(){return__awaiter(this,void0,Promise,function*(){});}}__decorate([AnyDecorator(),__metadata('design:type',Function),__metadata('design:paramtypes',[]),__metadata('design:returntype',Promise)],Foo.prototype,"foobar",null);

Cheers
Chris

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions