Skip to content

plugin-proposal-decorators implementation does not accurately reflect stage-2 description. #12654

@Enteleform

Description

@Enteleform

Bug Report

 

Description

According to the current Stage-2 Description, two parameters should be passed to decorators when they are called:

element: (class | function | {get, set})

context: {kind, name, isStatic}

 

Input Code

function decorated(element, context){
  console.log({element, context})
}

class Foo{
  @decorated
  bar(){}
}

 

Current Output

{
  element: {
    key:       "bar",
    kind:      "method",
    placement: "prototype",
    descriptor: {
      configurable: true,
      enumerable:   false,
      value:        ƒ bar(),
      writable:     true,
    },
  },
  context: undefined,
}

 

Expected Output

{
  element: ƒ bar(),
  context: {
    kind:     "method",
    name:     "bar",
    isStatic: false,
  },
}

 

Babel Configuration / Environment

This is reproducible in the REPL, so I did not include my personal configuration.

 

Additional context

I believe that the function signature of decorators should accurately reflect the current state of the proposal, to minimize erroneous code & the need for refactoring when the specification is finalized & implemented.

Also, the Return Value implementation should match the current description as well.

Update:
It also seems like the kind values are inconsistent. For example, the decorator of a get member receives {kind: "method"} instead of the described Context of {kind: "getter"}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions