-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
plugin-proposal-decorators implementation does not accurately reflect stage-2 description. #12654
Copy link
Copy link
Closed
Labels
i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
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"}.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue