Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indentation formatting nested destructering is incorrect #16869

Closed
jvanoostveen opened this issue Jun 30, 2017 · 5 comments
Closed

Indentation formatting nested destructering is incorrect #16869

jvanoostveen opened this issue Jun 30, 2017 · 5 comments
Labels
Bug A bug in TypeScript Domain: Formatter The issue relates to the built-in formatter Fixed A PR has been merged for this issue

Comments

@jvanoostveen
Copy link

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)

@aluanhaddad
Copy link
Contributor

This works correctly in nightly

@jvanoostveen
Copy link
Author

Issue still present in version 2.4.2. :(

@mhegazy
Copy link
Contributor

mhegazy commented Aug 23, 2017

Should be working correctly in latest drop of TypeScript (TS 2.5.1 or later). VSCode ships with an older version of TypeScript. Please see Using Newer TypeScript Versions documentation for more details on updating your VSCode to use a different version of TypeScript.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Aug 23, 2017
@mhegazy mhegazy added this to the TypeScript 2.5 milestone Aug 23, 2017
@mhegazy mhegazy added Bug A bug in TypeScript Domain: Formatter The issue relates to the built-in formatter labels Aug 23, 2017
@mhegazy mhegazy closed this as completed Aug 23, 2017
@jvanoostveen
Copy link
Author

@mhegazy We're running Typescript 2.5.3 now, but the problem still exists...

@mhegazy
Copy link
Contributor

mhegazy commented Oct 16, 2017

here is what i see locally:
animation

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: Formatter The issue relates to the built-in formatter Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants