3 ms·
`concat` doesn't happen in place, it builds a new array: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
by dunham 8y ago
`concat` doesn't happen in place, it builds a new array:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
- WorldMaker 8y agoInteresting. Then that should be a fixable bug in TS' lib files then.
- WorldMaker 8y agoThere's an issue mentioning it with a PR Welcome sign up: https://github.com/Microsoft/TypeScript/issues/27545 https://github.com/Microsoft/TypeScript/issues/27545
- WorldMaker 8y agoAh, and there is at least one PR specifically for it: https://github.com/Microsoft/TypeScript/pull/25716 https://github.com/Microsoft/TypeScript/pull/25716
- funkaster 8y agoTrue, but does not mean the type of the array that should be built should be of different types. I think the sane definition by Typescript is that it should be of the same type: that's why it's an instance method and not a static one. If this was a static method (Array.concat(a, b)), I would agree that would be a good assumption, that the type of the resulting array should be union of the types of the arguments.