dprint-plugin-typescript icon indicating copy to clipboard operation
dprint-plugin-typescript copied to clipboard

Multi-line JSX does not handle whitespace correctly with preferSingleLine

Open declanvong opened this issue 2 years ago • 2 comments

Describe the bug

dprint-plugin-typescript version: 0.80.2

When preferSingleLine is enabled, dprint incorrectly collapses multi-line JSX, as there is no space in the rendered output of the original code (whitespace is collapsed), but there is a space in the formatted code.

Prettier doesn't collapse it at all, which makes me tend to believe that dealing with it is a PITA and it's probably better from a correctness perspective to just leave it alone and not collapse it.

Input Code

function Component({a, b}) {
  return (
      <Foo>
        {a}
        {b}
      </Foo>
  );
}

Expected Output

function Component({a, b}) {
  return (
      <Foo>
        {a}
        {b}
      </Foo>
  );
}

Actual Output

function Component({ a, b }) {
  return <Foo>{a} {b}</Foo>;
}

declanvong avatar Jan 23 '23 05:01 declanvong