Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing has method on decorators context #9079

Open
lucacasonato opened this issue Jun 18, 2024 · 0 comments
Open

Missing has method on decorators context #9079

lucacasonato opened this issue Jun 18, 2024 · 0 comments
Assignees
Labels
Milestone

Comments

@lucacasonato
Copy link
Contributor

Describe the bug

The decorators context is missing the has method that should be present as per spec: https://arai-a.github.io/ecma262-compare/?pr=2417&id=sec-createdecoratoraccessobject

Babel handles this correctly: https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=MYewdgzgLgBApgDwIYFsAOAbOMC8MAUUSATgOZxQA0MoYUiUAlLgHwwDeAUDDeNBzDCo41ANYBLMABMYAX1y86DANzdFEEFgB0GEKXxqeAAyEo4ALhgAiACTtTcLVBABlKMUn7GsqwB0wEtKWdoY8ivQIUFqBUqGy_lZIwMBwEBBWMJLhDKwwIWFh-InJqemZYNmRjHEJABZIZVm0EVFJKWm5-QUEVvWNFc0MWm2l1QXxYFbkUBlN4C3DJR04bF0FRdOzA_NDI2ljYRNWEBRbla1LEJ1c3T0nM-Xni-0QBzwTRpRqjKqyqpwAegBMAAjgBXcTAUTUMDgAC0iHqYOg4gAbtgpHAUCAYAB3cRQWowVEkcQgZEwIhkCiUgCeaFSnGAGAaVwAYiAcTcYAABRCoTDYDRmACyFFqICk-GY7ABACpMqRYcRsHKAbJOGo-ch0FgYNMYMK4ABxCj0YjSjihFVQMHECruMFwVTvTU8bUCvX3Q0gMwuM1wC0AfRl8sVytV6rdvP5uuwew0xBgADNOQAjEgKKwZgBeabBOZzVn-7tjgpT4jgGCkAHlkwAhYggURwMAAERVqCueCswHqYHIMDMxc4GqAA&debug=false&forceAllTransforms=false&modules=false&shippedProposals=false&circleciRepo=&evaluate=true&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env%2Creact%2Cstage-2%2Ctypescript&prettier=false&targets=&version=7.24.7&externalPlugins=&assumptions=%7B%7D

Input code

const example = (target, context) => {
  const { name, kind } = context;
  console.log(
    `name: "${name.toString()}"\nkind: ${
      context.kind
    }\n"access" in context => ${
      ("access" in context)
    }\n"has" in context.access => ${
      ("has" in context.access)
    }\n"get" in context.access => ${
      ("get" in context.access)
    }\n"set" in context.access => ${
      ("set" in context.access)
    }\n`,
  );
};

// quick, non-exhaustive demo with various target types
class Foo {
  @example someMethod() {/* ignore */}

  @example get someGetter() {
    return true;
  }

  @example set someSetter(_) {/* ignore */}

  @example accessor foobar = "bazbuzz";

  @example fieldOfBrokenDreams = "change me";
}

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false,
      "decorators": true
    },
    "target": "es2022",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    },
    "transform": {
      "legacyDecorator": false,
      "decoratorVersion": "2022-03"
    },
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true,
"experimental": {

}
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.6.1&code=H4sIAAAAAAAAA42STU%2BDQBCG7%2FyKCekBDMK9pMYYoyfjodcmdgtT2BR26u5Qawn%2F3V3ohzVEve3H8z6zu7MZKcOAe1FvK4QZBCx0gRxBRopxzyHM7qD1wM0t2IISNUawkSqHzvJHLD0SVGFcURHYKcDSsVPwJ60bxExz1lIVQdj5C%2BUMU5i0PQknT%2ByW%2B6VuoXyRZWiMD1Kd9t1pzplgBAjP4VJcbcQD%2B0MwDl0k9in%2BloxDF4n5j2QcOkuWkR2Fqdelnpck8N7IbBOBInWL%2B1I0huUOIcea4ENyCTuhJTUGhm4Cf27ReFklbNknor6h96emG6rxBbmkPAihTW5AFoo0wk3Sed85J3LsMzKjdmx%2FOI3caAWsG3S%2F4Dpjjpn5kHn7tcBwZdKwJloJbX%2BXvxKHVXM4%2BOkVuJZY5a%2FrB00bVI8aRW0cnJVCFQg1WrzzvgA2of6g2gIAAA%3D%3D&config=H4sIAAAAAAAAA3VQuwrDMAzc8xVBcwohhQ6du3btbhwluPiF5EBDyL%2FXzjuULkbSWXenG7I8hzdLuOdDLGPjBTHS1scJ9zaIT5xA6D2yJOUDFCsaOEGN0IzbrEbpSARHHKFAHU7AOOMQBLUYEh9yVVbVwgXaOcYzFxhlVdMf3UhnPCHzj6gRttXb%2FlmRhOXGkTkSaWyF7B%2Br1f9HvJBYOZsMJ7uX8go7%2B%2FSAcXU3aS8hpqDmA2%2Bwf1pv2XRA8XPdTDEVGeDHIymDMXI98WVjNn4BiKKsl6YBAAA%3D

SWC Info output

No response

Expected behavior

name: "someMethod"
kind: method
"access" in context => true
"has" in context.access => true
"get" in context.access => true
"set" in context.access => false

name: "someGetter"
kind: getter
"access" in context => true
"has" in context.access => true
"get" in context.access => true
"set" in context.access => false

name: "someSetter"
kind: setter
"access" in context => true
"has" in context.access => true
"get" in context.access => false
"set" in context.access => true

name: "foobar"
kind: accessor
"access" in context => true
"has" in context.access => true
"get" in context.access => true
"set" in context.access => true

name: "fieldOfBrokenDreams"
kind: field
"access" in context => true
"has" in context.access => true
"get" in context.access => true
"set" in context.access => true

Actual behavior

name: "someMethod"
kind: method
"access" in context => true
"has" in context.access => false
"get" in context.access => true
"set" in context.access => false

name: "someGetter"
kind: getter
"access" in context => true
"has" in context.access => false
"get" in context.access => true
"set" in context.access => false

name: "someSetter"
kind: setter
"access" in context => true
"has" in context.access => false
"get" in context.access => false
"set" in context.access => true

name: "foobar"
kind: accessor
"access" in context => true
"has" in context.access => false
"get" in context.access => true
"set" in context.access => true

name: "fieldOfBrokenDreams"
kind: field
"access" in context => true
"has" in context.access => false
"get" in context.access => true
"set" in context.access => true

Version

1.6.1

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants