Issue
A readonly array has a readonly length:
type Test1 = Pick<readonly string[], 'length'>; // { readonly length: number }
A readonly tuple doesn't:
type Test2 = Pick<readonly [number?], 'length'>; // { length: 0 | 1 }
declare const x: readonly [number?];
x.length = 0; // wat
Why is this? It seems contrary to the purpose of readonly.
Solution
This was indeed a bug and is fixed in TS 4.7.
Answered By - Doofus
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.