Skip to content

Default formatter results strange indents for TypeScript code. #39710

@seiyab

Description

@seiyab

TS Template added by @mjbvz

TypeScript Version: 4.0.0-dev.20200720

Search Terms

  • format, formatter, formatting
  • indent

Abstract

When I open object literal brace after comma in function arguments and break line immediately, format results strange indent.

Example

Code I wrote is like below. And I think following indents is one of desired formats.

f(
  foo, {
    bar: 'qux',
  },
);

When I save

f(
  foo, {
  bar: 'qux',
},
);

Desired

f(
  foo, {
    bar: 'qux',
  },
);

or

f(
  foo,
  {
    bar: 'qux',
  },
);

Issue Template

  • VSCode Version: 1.45.1, 1.48.0-insider
  • OS Version: macOS Catalina 10.15.5

Steps to Reproduce:

  1. enable formatOnSave.
  2. write a TypeScript file like bellow
// reproduce.ts
console.log(
  1, {
    a: 1,
  },
)
  1. save

Does this issue occur when all extensions are disabled?: Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions