Skip to content

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

@pineapplemachine

Description

@pineapplemachine

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";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions