constworks:DeepReadonly<['one'|'two',1|2]>=[1,2];// TS2322: Type 'number' is not assignable to type 'Readonly<"one" | "two">'.constdoesntwork:DeepReadonly<{x:['one'|'two',1|2],y:string}>={x:[1,2],y:'asd'};// no error
Apparently it's the inferring the array type and passing it back to the Array generic that messes up the case for tuples. Turns out this step can be avoided by passing the property type directly, then the generic gets even smaller:
Your code works incorrectly for tuple types:
That's a good observation, I haven't accounted for the tuples when designing it, thanks 👍
Perhaps, I'll revise it 🤓
Apparently it's the inferring the array type and passing it back to the
Arraygeneric that messes up the case for tuples. Turns out this step can be avoided by passing the property type directly, then the generic gets even smaller:Here's the playground with the tuple example you provided.
I don't get, what's the benefit over this simpler variant?
I don't see any apparent advantages, this one seems less verbose 🤔