Skip to main content
Version: Current (v7.0.0-beta.3)

@rjsf/utils no longer exports utilities no other RJSF package uses

Detect​

An import from @rjsf/utils, in your code, of any of:

  • canExpand, ariaDescribedByIds, dataURItoBlob, dateRangeOptions, getDateElementProps, parseDateString, toDateString, pad, findSchemaDefinition, getInputProps, getTemplate, getWidget, hashForSchema, hashString, sortedJSONStringify, mergeDefaultsWithFormData, replaceStringParameters, schemaParser, withIdRefPrefix, isValueEmpty.
  • DEFINITIONS_KEY, DEPENDENCIES_KEY, ENUM_KEY, IF_KEY, DISCRIMINATOR_PATH, FORM_CONTEXT_NAME, NAME_KEY, RJSF_PREFIX_KEY.

The type checker reports Module '"@rjsf/utils"' has no exported member 'canExpand'. (with the name you import), and the bundler or runtime fails to resolve it.

Change​

@rjsf/utils now exports only what another RJSF package uses. The ones RJSF still needs are unchanged, just no longer exported; the rest are deleted. Replace each import:

ExportUse instead
canExpand()registry.schemaUtils.canExpand(schema, uiSchema, formData)
ariaDescribedByIds()getControlDescribedBy({ id, presentation }), or widgetAriaProps() for a widget; for ariaDescribedByIds(id, true), which also named the examples list, pass [examplesId(id)] as getControlDescribedBy()'s second argument
dataURItoBlob()useFileWidgetProps() in a file widget, which gives each file's name, size and type; elsewhere, split the URL at ;base64,: the part before holds the type up to its first ; and the file name in a URI-encoded name= parameter, and new Blob([Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))], { type }) builds the blob. fetch(dataURL) keeps the name= parameter in the blob's type and is blocked by a connect-src policy that doesn't allow data:
dateRangeOptions(), getDateElementProps(), parseDateString(), toDateString(), pad()useAltDateWidgetProps() and DateElement, which build the date parts; outside a widget, the UTC getters of new Date(value) for parseDateString(), adding 1 to getUTCMonth() for its 1-based month (it gave -1 for every part of an empty value, threw Unable to parse date <value> for a string new Date() can't parse, where the getters give NaN, and gave 0 for the hour, minute and second when includeTime was false, where the getters give the parsed ones), new Date(Date.UTC(year, month - 1, day, hour, minute, second)).toJSON() for toDateString(), followed by .slice(0, 10) for toDateString(date, false), and String(value).padStart(width, '0') for pad()
findSchemaDefinition()registry.schemaUtils.retrieveSchema({ $ref }) in a field or widget. Without a registry, or for a $ref into another root, createSchemaUtils({ validator }, rootSchema).retrieveSchema({ $ref }). Both need a validator, and both resolve more than the definition: an allOf in it is merged and its if/then/else and dependencies are resolved against no data, and the result carries RJSF's Symbol markers. A $ref inside the definition is left as it is, and a $ref the root doesn't define throws, as before.
getInputProps()getBaseInputProps(), which takes a BaseInputTemplate's props: outside a template, pass it { schema, type, options, registry }, where registry needs only translateString, and pass getInputProps()'s fourth argument as its second, plainNativeInput, which also decides whether a number/integer field gets a text input with a numeric inputMode and pattern. It returns more than getInputProps() did: a title naming that numeric pattern, an accept, inputMode or pattern passed in its props in place of the derived one, and multiple set to undefined for any input but a file input, so it overrides a multiple spread before it, such as on an email input
getTemplate()getTemplates(registry, uiOptions), destructuring the template you need. It resolves only the names the registry holds: an override in ui:options under a name the registry has no template for, which getTemplate() returned, is left out, so read such a template from uiOptions yourself and name its props with isComponentType<P>()
getWidget()resolveWidget(schema, widget, registry.widgets), destructuring its Widget
hashForSchema()hashObject(), which hashes the schema the same way
hashString(), sortedJSONStringify()Nothing: copy their 6.x implementation. hashObject(x) is hashString(sortedJSONStringify(x)), so it neither returns the JSON nor hashes a string as hashString() did: hashObject('abc') hashes "abc", quotes included
mergeDefaultsWithFormData()getDefaultFormState(), or mergeObjects() for plain objects, which replaces an array where mergeDefaultsWithFormData() merged its items and has nothing in place of its mergeExtraArrayDefaults, defaultSupercedesUndefined and overrideFormDataWithDefaults arguments, so an undefined value always overwrites its default
replaceStringParameters()englishStringTranslator() for a TranslatableString; for a string of your own, replace %1, %2, … yourself
schemaParser()getValidationSchemas()
withIdRefPrefix()withRootIdRefPrefix(schema, {}), which prefixes a local # $ref with ROOT_SCHEMA_PREFIX and leaves a relative one as written, as 6.x did. Passing the real root instead gives a root with an $id that $id as the prefix, resolves relative $refs against it and re-spells those inside a nested $id, so a validator holding the root under ROOT_SCHEMA_PREFIX can't resolve them. Unlike 6.x, it takes only a schema object, not an array or a primitive
DEFINITIONS_KEY, DEPENDENCIES_KEY, ENUM_KEY, IF_KEY, DISCRIMINATOR_PATH, FORM_CONTEXT_NAMEThe string or path they hold: 'definitions', 'dependencies', 'enum', 'if', ['discriminator', 'propertyName'], 'formContext'
isValueEmpty(), NAME_KEY, RJSF_PREFIX_KEYNothing: they served RJSF's own code

retrieveSchema() and getDefaultFormState() take a SchemaContext first; see @rjsf/utils schema functions take a SchemaContext.

Verify​

No import from @rjsf/utils fails to resolve, and the type checker reports no missing export.

Also read: