Skip to content

Prefer breaking after = in type aliases if RHS is a conditional type chain #10325

@thorn0

Description

@thorn0

Reported here: #7948 (comment)

Should be worked on after merging #10222.

Prettier 2.2.1
Playground link

--parser typescript

Input:

export type SchemaToType<S extends Schema> = S extends SchemaLiteral
  ? SchemaLiteralToType<S>
  : S extends SchemaPrimitive
  ? SchemaPrimitiveToType<S>
  : S extends Schema.Record
  ? SchemaRecordToType<S>
  : S extends Schema.Array
  ? SchemaArrayToType<S>
  : S extends Schema.Intersection
  ? SchemaIntersectionToType<S>
  : S extends Schema.Union
  ? SchemaUnionToType<S>
  : S;

Output:

export type SchemaToType<S extends Schema> = S extends SchemaLiteral
  ? SchemaLiteralToType<S>
  : S extends SchemaPrimitive
  ? SchemaPrimitiveToType<S>
  : S extends Schema.Record
  ? SchemaRecordToType<S>
  : S extends Schema.Array
  ? SchemaArrayToType<S>
  : S extends Schema.Intersection
  ? SchemaIntersectionToType<S>
  : S extends Schema.Union
  ? SchemaUnionToType<S>
  : S;

Expected behavior:

export type SchemaToType<S extends Schema> =
  S extends SchemaLiteral
  ? SchemaLiteralToType<S>
  : S extends SchemaPrimitive
  ? SchemaPrimitiveToType<S>
  : S extends Schema.Record
  ? SchemaRecordToType<S>
  : S extends Schema.Array
  ? SchemaArrayToType<S>
  : S extends Schema.Intersection
  ? SchemaIntersectionToType<S>
  : S extends Schema.Union
  ? SchemaUnionToType<S>
  : S;

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions