4

I recently ran into this typescript syntax:

type Foo = | 5 | 6;

Turns out that this does compile, to my surprise. Is there any significance to that first pipe character? Or is it functionally equivalent to:

type Foo = 5 | 6;
Evert
  • 93,428
  • 18
  • 118
  • 189

1 Answers1

3

Leading pipe characters are ignored in union type definitions to give developers more formatting freedom.

You can check PR#12386 on the official TypeScript repository for more info.

vicpermir
  • 3,544
  • 3
  • 22
  • 34