Skip to content

Object literals in Angular templates are missing trailing commas #15897

@matmeylan

Description

@matmeylan

Prettier 3.1.1
Playground link

--parser angular
--trailing-comma all

Input:

<div
  *ngIf="{
    spacing: spacing$ | async,
    user: user$ | async,
  } as ctx"
  [ngClass]="{
    'px-lg': ctx.spacing == 'lg',
    'px-md': ctx.spacing == 'md',
    'px-xs': ctx.spacing == 'xs',
  }"
>
  Hi Prettier !
</div>

Output:

<div
  *ngIf="{
    spacing: spacing$ | async,
    user: user$ | async
  } as ctx"
  [ngClass]="{
    'px-lg': ctx.spacing == 'lg',
    'px-md': ctx.spacing == 'md',
    'px-xs': ctx.spacing == 'xs'
  }"
>
  Hi Prettier !
</div>

Expected behavior:
Trailing commas should be kept/inserted in object literals. This used to work on 2.8.

<div
  *ngIf="{
    spacing: spacing$ | async,
    user: user$ | async,
  } as ctx"
  [ngClass]="{
    'px-lg': ctx.spacing == 'lg',
    'px-md': ctx.spacing == 'md',
    'px-xs': ctx.spacing == 'xs',
  }"
>
  Hi Prettier !
</div>

Metadata

Metadata

Assignees

Labels

lang:angularIssues affecting Angular template (not general JS/TS issues used for Angular)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:needs discussionIssues needing discussion and a decision to be made before action can be taken

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions