Skip to content

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

@buehler

Description

@buehler

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:

class Foo {
    @AnyDecorator()
    public async foobar() {

    }
}

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

Actually it produces:

class Foo {
    foobar() {
        return __awaiter(this, void 0, void 0, function* () {
        });
    }
}
__decorate([
    AnyDecorator(), 
    __metadata('design:type', Function), 
    __metadata('design:paramtypes', []), 
    __metadata('design:returntype', void 0)
], Foo.prototype, "foobar", null);

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

class Foo {
    foobar() {
        return __awaiter(this, void 0, 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