ReSharper 8.2: TypeScript reformatting does not indent second line of a ternary expression

In a statement like:

positions.sort((a, b) => ( < ? -1 : ( > ? 1 :
     (a.position < b.position) ? -1 : (a.positionId > b.positionId) ? 1 : 0);

When asked to reformat this, ReSharper does not indent the second line.

I have it set to not align ternary expressions.

Comment actions Permalink

Apparently the answer to this was to turn on "Indent object literals/arrays/nested expressions" which I definitely did not expect to affect this sort of thing.

In general, I'm not particularly happy with how ReSharper indents large JSON object literals with multiple levels of nested arrays and such. It's impossible to have a large JSON structure included in your code without ReSharper wanting it to take immense amounts of space. There's no way to tell ReSharper that you're fine with this look:

{cl: "form-group", c: [
    {n: "label", t: " "}, {n: "br"},
    {n: "button", a: {type: "button"}, cl: "btn btn-default btn-sm", t: "Add", e: this.doAdd},

Instead, since the outer object literal spans multiple lines, it insists on producing this:

    cl: "form-group",
    c: [
        {n: "label", t: " "}, {n: "br"},
        {n: "button", a: {type: "button"}, cl: "btn btn-default btn-sm", t: "Add", e: this.doAdd},

Now, imagine this replicated over multiple lines and you can see how it might be a problem.

Comment actions Permalink

Hello Anthony.

  I filed a couple of tickets to YouTrack:

  You are welcome to track its status, comment and vote for it.

My apologies for the inconvenience.


Please sign in to leave a comment.