SchemaUtilsType gains canExpand and allowsAdditionalProperties
Detect
- Your code has a class or object typed as
SchemaUtilsTypethat you wrote yourself, rather than onecreateSchemaUtils()returns. - The type checker reports
Type 'MySchemaUtils' is missing the following properties from type 'SchemaUtilsType<...>': allowsAdditionalProperties, canExpand(the exact list and type arguments depend on your code).
Change
Add both methods. They answer with the form's own SchemaContext, which now carries the additionalPropertiesWhenAbsent setting, so delegate to an instance from createSchemaUtils() if you can:
class MySchemaUtils implements SchemaUtilsType {
+ canExpand(schema, uiSchema, formData) {
+ return this.inner.canExpand(schema, uiSchema, formData);
+ }
+ allowsAdditionalProperties(schema) {
+ return this.inner.allowsAdditionalProperties(schema);
+ }
}
Verify
- Your implementation compiles.
- Templates that call
registry.schemaUtils.canExpand(), as every theme'sObjectFieldTemplatenow does, show their Add button where you expect; see A custom ObjectFieldTemplate calls registry.schemaUtils.canExpand.
Also read: