benjamn / ast-types

Esprima-compatible implementation of the Mozilla JS Parser API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ClassDeclaration type is missing decorators

gaggarwal-patreon opened this issue · comments

commented

You can find the definition of ClassDeclaration here. Note that there doesn't exist a field for decorators even though it exists for several other nodes such as ClassAccessorProperty and ClassMethod.

However, it is possible to have a class decorator such as the following:

@sealed
class BugReport {
  type = "report";
  title: string;
 
  constructor(t: string) {
    this.title = t;
  }
}

In this case, the decorators field does exist on ClassDeclaration. Can we update the types to reflect this?

PR #660 has had this ready to go for two years. This really needs to be merged, as there's no shortage of angular code that makes use of class decorators.

I'll add that right now ChatGPT is generating jscodeshift codemods that rely on this functionality being present.