Skip to content

Suggestion: Allowing leading pipe in union type declarations #12071

Closed
@mariusschulz

Description

@mariusschulz

Currently, because of the leading | symbol , the following code is invalid TypeScript:

type ReduxAction =
  | { type: "INCREMENT" }
  | { type: "DECREMENT" }
  | { type: "SET_VALUE", value: number };

I suggest we relax the syntax such that a single leading pipe symbol is allowed (but not required) in a union type declaration. Flow and F#, for example, both allow this syntax.

This change is backwards-compatible and gives developers a little more code formatting freedom.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueHelp WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions