benjamn / ast-types

Esprima-compatible implementation of the Mozilla JS Parser API
MIT License
1.13k stars 195 forks source link

ClassDeclaration type is missing decorators #938

Open gaggarwal-patreon opened 1 year ago

gaggarwal-patreon commented 1 year ago

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?

ElonVolo commented 12 months ago

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.