Readonly vs. mutable
alex-dixon opened this issue ยท 1 comments
alex-dixon commented
๐ Feature request
Current Behavior
Type 'readonly string[] | undefined' is not assignable to type 'string[] | undefined'.
The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type 'string[]'.
Desired Behavior
Better interoperability with libraries that do not have readonly for all type definitions.
Suggested Solution
I'm not sure whether there's an option I like. A way to ignore the distinction at the Typescript level? .asMut
?
Who does this impact? Who is this for?
People using schema with typescript libraries that accept mutable data type definitions instead of readonly variants as input.
Describe alternatives you've considered
A recursive type function that casts all readonly types to mutable.
Additional context
Your environment
Software | Version(s) |
---|---|
@effect/schema | 0.19.3 |
TypeScript | 5.0.4 |
alex-dixon commented