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

Ast: Distiguish class/object methods with ordinary function expressions in FunctionType #7385

Closed
KermanX opened this issue Nov 21, 2024 · 3 comments
Assignees
Labels
C-enhancement Category - New feature or request

Comments

@KermanX
Copy link
Contributor

KermanX commented Nov 21, 2024

The FunctionType enum already distinguishes function declarations and expressions. However, class methods and object methods are also considered to be function expressions, although they are different in some ways. For example:

const object = {
  fn: function(){},
  method(){}
}
object.fn.prototype     //=> {}
object.method.prototype //=> undefined

A possible solution is adding MethodFunction to the FunctionType enum.

@KermanX KermanX added the C-enhancement Category - New feature or request label Nov 21, 2024
@KermanX KermanX changed the title Ast: Distiguish class/object method in FunctionType Ast: Distiguish class/object methods with ordinary function expressions in FunctionType Nov 21, 2024
@overlookmotel
Copy link
Contributor

Similar to: oxc-project/backlog#142

@Boshen Boshen self-assigned this Nov 21, 2024
@Boshen
Copy link
Member

Boshen commented Nov 25, 2024

This conforms to estree. The caller will need to figure out whether it's a function inside a class / object or not.

@Boshen Boshen closed this as not planned Won't fix, can't repro, duplicate, stale Nov 25, 2024
@overlookmotel
Copy link
Contributor

Personally, I don't think we need to conform to ESTree. Serialization can take care of translating our AST to ESTree-compatible AST. But I think it's fine to close this issue, as oxc-project/backlog#142 is sufficiently similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category - New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants