typescript-tuple icon indicating copy to clipboard operation
typescript-tuple copied to clipboard

Add support for readonly tuples

Open cshaa opened this issue 6 years ago • 2 comments
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[].

cshaa avatar May 24 '19 12:05 cshaa

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] };

cshaa avatar May 24 '19 12:05 cshaa

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.

KSXGitHub avatar May 28 '19 08:05 KSXGitHub