You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merging const arrays should result in a new const array
Use Cases
Convenience
Examples
constARR1=['a','b']asconst;// type is: readonly ['a', 'b']constARR2=['x','y']asconst;// type is: readonly ['x', 'y']constCONCAT=[...ARR1, ...ARR2]asconst;// type is: readonly ('a', 'b', 'x', 'y')[]// but should be: readonly ['a', 'b', 'x', 'y']
Checklist
My suggestion meets these guidelines:
[?] This wouldn't be a breaking change in existing TypeScript/JavaScript code
This wouldn't change the runtime behavior of existing JavaScript code
This could be implemented without emitting different JS based on the types of the expressions
This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
I think there's an issue somewhere here that also asks for this, but I can't remember where.
I would personally also like this because the current way of emulating this with recursive types, or conditional types (or both) is clunky, and makes you reach the max instantiation depth sooner
Search Terms
const array concat merge
Suggestion
Merging const arrays should result in a new const array
Use Cases
Convenience
Examples
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: