A date element's range and yearsRange are readonly tuples
Detect
- Your custom alt-date widget passes a date element's
rangeoroptions.yearsRangeto a parameter typed[number, number], and the type checker rejects the call:error TS4104: The type 'readonly [number, number]' is 'readonly' and cannot be assigned to the mutable type '[number, number]'.
Change
Mark the parameter readonly, or destructure the range as @rjsf/mantine's AltDateWidget does:
- function yearOptions(range: [number, number]) {
+ function yearOptions(range: readonly [number, number]) {
Verify
- The widget compiles. Nothing changes at runtime. The other typed options are listed in ui:options types the options RJSF's widgets read.
Also read: