-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Allow array concat to concat arrays of different types #31355
Copy link
Copy link
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: 3.5.0-dev.20190511
Code
[0].concat('')
// Argument of type '""' is not assignable to parameter of type 'number | ConcatArray<number>'.Expected behavior:
The concated array has type (number|string)[].
Actual behavior:
Error.
Possible fix:
In
Line 1231 in b7fe99a
| concat(...items: ConcatArray<T>[]): T[]; |
interface Array<T> {
- concat(...items: ConcatArray<T>[]): T[];
+ concat<U>(...items: ConcatArray<U>[]): (T|U)[];Playground Link:
https://www.typescriptlang.org/play/#src=%5B0%5D.concat(%5B''%5D)
Related Issues:
#29604
Search Terms:
array concat
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created