Skip to content

[3.4.0, 3.4.1] Regression on decorators + async + jsdoc  #16889

@ClementValot

Description

@ClementValot

Prettier 3.4.0 (Also tested on 3.4.1)
Playground link

--parser typescript
--print-width 120
--single-quote
--trailing-comma es5

Input:

const myDecorator = (target, propertyKey, descriptor) => {
  console.log(descriptor.value);
}

class myClass {
  @myDecorator
  /** 
   * The method description
   *
  */
  async myMethod(foo: Foo, bar: Bar) {
    console.log(foo);
  }
}

Output:

const myDecorator = (target, propertyKey, descriptor) => {
  console.log(descriptor.value);
};

class myClass {
  @myDecorator
  async /**
   * The method description
   *
   */
  myMethod(foo: Foo, bar: Bar) {
    console.log(foo);
  }
}

Expected output:

No change 

Why?

The async keyword gets hoisted above the jsdoc. Even worse, next prettier run adds a ; after it, breaking the syntax :D

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions