Skip to content

Keep multiple property and argument decorators on same line as argument when possible (Babylon, TypeScript) #1974

@mafredri

Description

@mafredri

Prettier 1.10.2
Playground link

--parser typescript

Input:

export class CoreModule {
  @Input() @Output() prop: string;

  constructor(@Optional() @SkipSelf() parentModule: CoreModule) {}
}

Output:

export class CoreModule {
  @Input()
  @Output()
  prop: string;

  constructor(
    @Optional()
    @SkipSelf()
    parentModule: CoreModule
  ) {}
}

Expected output:

No difference between input and output.

If we did the same thing with only one decorator, the result would be:

export class CoreModule {
  @Input() prop: string;

  constructor(@Optional() parentModule: CoreModule) {}
}

In this sense I don't think breaking on multiple decorators adds any value, instead adds more visual noise and makes it harder to spot arguments in e.g. the constructor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:javascriptIssues affecting JSlang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions