Skip to content

Better typings for Array.concat() - #33606

Closed
Jack Bates (jablko) wants to merge 2 commits into
microsoft:masterfrom
jablko:patch-9
Closed

Jack Bates (jablko) wants to merge 2 commits into
microsoft:masterfrom
jablko:patch-9

Conversation

@jablko

@jablko Jack Bates (jablko) commented Sep 26, 2019 •

Copy link
Copy Markdown
Contributor

Fixes #26378
Fixes #26976

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably need to keep at least the less-generic overload around as the first overload.

As it is, the free U parameter will prevent inference from working in cases where one is trying to build a homogeneous array; especially when the array includes function or object types that might have methods.

const foo = [(a: string) => a]
const bar = foo.concat(b => b) // implicit any error
@jablko
Jack Bates (jablko) force-pushed the patch-9 branch 2 times, most recently from 337078d to eb23428 Compare September 27, 2019 17:54
@jablko

Copy link
Copy Markdown
Contributor Author

Jessica Franco (@Jessidhia) Thank you for this feedback! I've now updated the PR accordingly.

@RyanCavanaugh

Copy link
Copy Markdown
Member

Rolled into #33645

@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
@typescript-bot

Copy link
Copy Markdown
Contributor

The TypeScript team hasn't accepted the linked issue #26378. If you can get it accepted, this PR will have a better chance of being reviewed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants