dprint / dprint-plugin-typescript

TypeScript and JavaScript code formatting plugin for dprint.
https://dprint.dev/plugins/typescript
MIT License
248 stars 50 forks source link

dprint moves `else` to the wrong `if` #632

Closed nicolo-ribaudo closed 2 months ago

nicolo-ribaudo commented 2 months ago

Describe the bug

dprint-plugin-typescript version: x.x.x

Input Code

https://dprint.dev/playground/#code/JYMwFAhglA3qYCNYGMD2A7AzqgNgUwDodUBzMABigG4BfGvHTPAAngBMUNt8jSwBGavUZ4YaLLkLEyAJiFA/config/N4XyA/plugin/typescript

if(a){if(b){console.log(0);}}else if(d){console.log(1);}else{console.log(2);}

Expected Output

Something so that if a is false and d is true that code logs 1

Actual Output

if (a) if (b) console.log(0);
else if (d) console.log(1);
else console.log(2);

which, when a is false, logs nothing.

dsherret commented 2 months ago

Thanks! That's pretty bad. Fixed in 0.90.5