An unannotated uiSchema variable no longer fits the typed options
Detect
- Your TypeScript code holds a uiSchema in a variable with no type annotation, and sets
yearsRangeorshapein it. Inference widensyearsRange: [2000, 2030]tonumber[]andshape: 'heart'tostring, and the type checker rejects the variable where it is passed as a uiSchema.
Change
Annotate the variable, or mark those values as const:
- const uiSchema = { 'ui:options': { yearsRange: [2000, 2030] } };
+ const uiSchema: UiSchema = { 'ui:options': { yearsRange: [2000, 2030] } };
Don't mark the whole uiSchema as const. That also makes arrays such as ui:order and ui:enumNames read-only, which don't fit.
Verify
- The uiSchema compiles. Nothing changes at runtime. The option types are listed in ui:options types the options RJSF's widgets read.
Also read: