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

Multi-line `export type MyType = ("a" | "b" | "c")` does not respect `"operatorPosition": "sameLine"` setting

Open pineapplemachine opened this issue 3 months ago • 0 comments

Describe the bug

When a type union expression spans multiple lines, the operatorPosition setting is not respected. I'm aware that TypeScript documentation for union types uses | operators at the start of a line, but I think this is inconsistent and arbitrary and would prefer not to format it this way.

Perhaps a unionAndIntersectionType.operatorPosition setting should be added?

dprint-plugin-typescript version: 0.95.13

Input Code

export type MyType = (
    "option_a" |
    "option_b" |
    "option_c" |
    "option_d" |
    "option_e" |
    "option_f"
);

Expected Output

With "operatorPosition": "sameLine" config, this would be the expected output:

export type MyType = (
    "option_a" |
    "option_b" |
    "option_c" |
    "option_d" |
    "option_e" |
    "option_f"
);

Actual Output

The sameLine option is not respected:

export type MyType =
    | "option_a"
    | "option_b"
    | "option_c"
    | "option_d"
    | "option_e"
    | "option_f";

pineapplemachine avatar Nov 28 '25 13:11 pineapplemachine