typescript-tuple
typescript-tuple copied to clipboard
Add support for readonly tuples
trafficstars
With TS 3.4 it became common practice to create tuples with [a, b, c] as const. This is really convenient, however the resulting tuple is readonly. It would be awesome to add support for these readonly tuples, right now I get error readonly (something) is not assignable to any[].
What I use now is a Writealso<T> type that removes readonly from the tuple:
type Writealso<T> = { -readonly [key in keyof T]: T[key] };
Sadly, I'm stuck here (I actually have been stuck there for longer than the issue). So until it is resolved, no new feature from me.