-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Array concat has wrong types #47351
Copy link
Copy link
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do this
Milestone
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do this
Type
Fields
Give feedbackNo fields configured for issues without a type.
Bug Report
A not-uncommon JS idiom is
[].concat(x || [], y || [], z || [])as a faster, simpler, more backwards-compatible[x, y, z].flatMap(x => x || []). However, when I try, I get type errors.🔎 Search Terms
array concat
concat overload
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
🙂 Expected behavior
No type errors (except perhaps that the variable may be
anyuntil i provide an explicit type for the resulting array), because this is valid JavaScript since at least ES3.