Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Typescript/Flow: Inconsistent union and intersection type multiline formatting #3986

@albertorestifo

Description

@albertorestifo

Prettier 1.10.2
Playground link

--parser typescript

Input:

type IntesectionType = VeryLongTypeA & VeryLongTypeB & VeryLongTypeC & VeryLongTypeD & VeryLongTypeE

type UnionType = VeryLongTypeA | VeryLongTypeB | VeryLongTypeC | VeryLongTypeD | VeryLongTypeE

Output:

type IntesectionType = VeryLongTypeA &
  VeryLongTypeB &
  VeryLongTypeC &
  VeryLongTypeD &
  VeryLongTypeE;

type UnionType =
  | VeryLongTypeA
  | VeryLongTypeB
  | VeryLongTypeC
  | VeryLongTypeD
  | VeryLongTypeE;

Expected behavior:

type IntesectionType = 
  & VeryLongTypeA
  & VeryLongTypeB
  & VeryLongTypeC
  & VeryLongTypeD
  & VeryLongTypeE;

type UnionType =
  | VeryLongTypeA
  | VeryLongTypeB
  | VeryLongTypeC
  | VeryLongTypeD
  | VeryLongTypeE;

I think the Interections type should use the same format as the one used for the Union type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:intersection typesarea:union typeslang:flowIssues affecting Flow-specific constructs (not general JS issues)lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)status:needs discussionIssues needing discussion and a decision to be made before action can be taken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions