When I am using fluent interfaces in TypeScript I normally want different method calls on different lines while by default prettier tries to format it in one single line (if not too long). A similar behavior for union types.
It seems that prettier supports a workaround by adding an empty comment (//
), see the examples below.
The question: Is this //
-workaround an official feature of prettier and if yes then where do I find the documentation for that?
const x = a().b().c();
/* prettier output:
const x = a().b().c();
*/
const y = a()
.b()
.c();
/* prettier output:
const y = a().b().c();
*/
const z = a() //
.b()
.c();
/* prettier output:
const z = a() //
.b()
.c();
*/
type A =
| "x"
| "y"
| "z";
/* prettier output:
type A = "x" | "y" | "z";
*/
type B =
| "x" //
| "y"
| "z";
/* prettier output:
type B =
| "x" //
| "y"
| "z";
*/