Skip to content

TS: Inconsistent spacing for comment-only object expression vs object type #19579

Description

@leaysgur

Prettier v3.9.4
Playground link

--parser typescript

Input:

// --- OK ---

var b = [
  /*c*/
]
type B = [
  /*c*/
]

// --- NG? ---

var a = {
  /*c*/
}
type A = {
  /*c*/
}

Output:

// --- OK ---

var b = [/*c*/];
type B = [/*c*/];

// --- NG? ---

var a = {/*c*/};
type A = { /*c*/ };

Expected output:

// --- OK ---

var b = [/*c*/];
type B = [/*c*/];

// --- NG? ---

var a = {/*c*/};
type A = {/*c*/};

Why?

Having a space inside the braces only for the object type seems inconsistent.
(Or is it intended? #19287 👀)

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions