镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
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:

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

Activity

  1. mhegazy commented on Apr 28, 2016

    @mhegazy
    Contributor

    looks like a bug alright.

  2. ghost closed this as completedin #9156on Jun 14, 2016
  3. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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