Skip to content

"this" inside the decorator #72

@mjesun

Description

@mjesun

What should be the value of "this" inside the decorator? For example if you do something like:

@Decorators.decorate
class A {}

When being inside decorate, the value of this should be Decorators, right?

I'm asking that because I haven't been able to find this inside the proposed specification, and I think it's nice to have it defined. Also, if that's the case, the current plugin for babel (the babel-plugin-transform-decorators-legacy) should be changed to support it. Right now the compilation is done as:

(_dec = Decorators.decorate, _dec(_class = function () { ... }))

Which would be incorrect (this is undefined in strict mode, or the global object in loose mode).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions