Skip to content

Indentation formatting nested destructering is incorrect #16869

Closed
@jvanoostveen

Description

@jvanoostveen

TypeScript Version: 2.4.1

Code

Provided the following code:

let a = {
  b: 1,
  c: 2,
  d: {
    e: 'a',
    f: 'b',
    h: 'c'
  }
};

export let test = (
  multi: typeof a,
  line: boolean,
  params: boolean
): boolean => {
  let {
    d: {
      e,
      f,
      h
    }
  } = a;

  return true;
};

After formatting, the function will be:

export let test = (
  multi: typeof a,
  line: boolean,
  params: boolean
): boolean => {
  let {
    d: {
      e,
    f,
    h
    }
  } = a;

  return true;
};

The f and h in the destruct are unidented one position.
When I add a destruct before the d (for example c), then the formatting is correct.

  let {
    c, // <- one before the nested destruct.
    d: {
      e,
      f,
      h
    }
  } = a;

Example: https://goo.gl/9JqSRu right click -> Format Code

(original issue was posted here: vvakame/typescript-formatter#105)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: FormatterThe issue relates to the built-in formatterFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions