Hacker News new | ask | show | jobs
by vosper 3354 days ago
> (Foo | undefined)[]

This says "either an array of Foo or an array of undefined", right? Not "either an array of Foo or just undefined"?

2 comments

No, (Foo | undefined)[] means an array of elements that are either of type Foo or are undefined.

Foo[] | undefined[] means either 1) an array of Foo, or 2) an array of undefined.

Ahh got it - thanks!
It says an array whose elements can be either Foo or undefined.