A bare UiSchema no longer fits a form whose data has a narrow index signature
Detect
- In your code: a bare
UiSchemaor aUiSchema<GenericObjectType>passed as theuiSchemaof aFormwhoseformDatais aRecord<string, string>, aRecord<string, string>[]or similar. - In your code: a
UiSchema<{ meta: any }>used where aUiSchema<{ meta: string }>, or any other type formeta, is expected. - The type checker reports
Type '…' is not assignable to type '…'.(TS2322) on thatuiSchema.
Change
Each key of that index signature holds a UiSchema for its value, which the unknown entries of an untyped UiSchema don't fit; see Entries read from an untyped UiSchema are unknown. A Record<string, unknown> target is fine, since its entries are as open as the untyped one's. Annotate the uiSchema with the data it describes:
-const uiSchema: UiSchema = { notes: { 'ui:widget': 'textarea' } };
+const uiSchema: UiSchema<Record<string, string>> = { notes: { 'ui:widget': 'textarea' } };
Verify
- The type checker accepts the
uiSchemaon the form. - Nothing changes at runtime.
Also read: