~~ lineWidth: 40 ~~
== should format ==
export type T = string|number;

[expect]
export type T = string | number;

== should go multi-line by default when a type exceeds line width ==
export type T = string | test | string | number;

[expect]
export type T =
    | string
    | test
    | string
    | number;

== should change to being a single line when too short ==
export type T = test | test
    | string;

[expect]
export type T = test | test | string;

== should change to be on multiple lines when the first and second are on different lines ==
export type T = test
    | test | other;

[expect]
export type T =
    | test
    | test
    | other;

== should handle the separator being on the next line ==
export type T =
    | test
    | test
    | other;

[expect]
export type T =
    | test
    | test
    | other;

== should handle comments around separators ==
export type T =
    // testing
    /*1*/ | /*2*/ test /* 3*/
    /*4*/ | test // 5
    | other;

[expect]
export type T =
    // testing
    /*1*/ | /*2*/ test /* 3*/
    /*4*/ | test // 5
    | other;

== should handle block comment on current line ==
export type T = /* test */ t | u;
export type U = /* test */
t|u

[expect]
export type T = /* test */ t | u;
export type U = /* test */
    t | u;

== should handle block comment on next line ==
export type T =
    /* test */
    test | test;

[expect]
export type T =
    /* test */
    test | test;

== should handle block comment on next line when multi-line ==
export type T =
    /* test */
    test | test | test | tttttttttttttttt;

[expect]
export type T =
    /* test */
    | test
    | test
    | test
    | tttttttttttttttt;

== should handle a block comment on the same line when going multi-line ==
export type T = /*1*/ testing | testing | testing | testing;

[expect]
export type T =
    | /*1*/ testing
    | testing
    | testing
    | testing;

== should keep block comment at top of union ==
export type T =
    (
        /*1*/
        | testing
        | testing
        | testing
        | testing
    );

[expect]
export type T = (
    /*1*/
    | testing
    | testing
    | testing
    | testing
);

== should handle union in type parameters ==
class Test<T extends string | number | test | test, U extends string | number | test | test> {}

[expect]
class Test<
    T extends
        | string
        | number
        | test
        | test,
    U extends
        | string
        | number
        | test
        | test,
> {}

== should keep on a single line when the type has an object type last that spans multiple lines ==
type Test = Test | Testing | {
    testing: string;
};

[expect]
type Test = Test | Testing | {
    testing: string;
};

== should keep non-multi-line when all the union types are object types ==
type Test = {
    testing: string;
} | {
    other: string;
};

[expect]
type Test = {
    testing: string;
} | {
    other: string;
};

== should allow the last node to be on a single line ==
type Test = testing | {
    testing: string;
} | test;

[expect]
type Test = testing | {
    testing: string;
} | test;

== should not allow the last node to be a single line when the second last one isn't ==
type Test = testing | {
    testing: string;
} | test | test;

[expect]
type Test =
    | testing
    | {
        testing: string;
    }
    | test
    | test;
