react-jsonschema-form
react-jsonschema-form copied to clipboard
Converted the fields to Typescript
trafficstars
Reasons for making this change
- Updated the
@rjsf/utilstypes and functions based on necessary changes needed for the conversion as follows:- In
types.tssome improvements and new types were discovered as follows:- Modified the
RJSFSchemato add the non-standardenumNamesproperty onto theJSONSchema7to support theFields - Added a new
EnumOptionsTyperequired for some of the fields - Added a new
UnsupportedFieldPropstype for the newUnsupportedFieldTemplateonTemplatesType - Removed the
fieldsproperty onFieldTemplatePropssince that data can be easily obtained from theregistry - Added the
rawErrorsproperty toArrayFieldTemplatePropssince it was neededArrayField - Added the missing
Tgeneric on a few uses ofIdSchemaproperties on a few types - Updated the
WidgetPropstype to combine theoptionsproperty with an additional, optionalenumOptionsproperty as needed by widgets - Updated the
UIOptionsBaseTypeto have it combined with theTemplatesTypemaking it require theTandFgenerics as well as adding the following new properties:classNameswas added as a breaking change (it used to simply beclassNamesinUiSchemabut now it will beui:classNamesorui:options: { classNames }- This makes
classNamesconsistent with all the other ui options
- This makes
orderableandremovablewere added to support theArrayFieldwidgetwas added to support many of theFields
- Updated
UIOptionsTypeto also take theTandFgenerics - Updated
SchemaUtilsType.retrieveSchema()to make theformDataparameter optional, like it already is on the wrapped function
- Modified the
- Updated the
getUiOptions()function to add theTandFgenerics to the return value type - Updated
getWidget()to make thewidgetproperty optional, updating the tests accordingly - Updated
isCustomWidget()to makeuiSchemadefault to an empty object if missing, updating the tests accordingly - Updated
optionsListto remove theenumNameshack and to return the newEnumOptionsType[] | undefinedtype
- In
- Updated
FieldTemplateforantdto remove the commented outfieldsvariable since it was removed from theFieldTemplateProps - Refactored
ArrayField.jstoArrayField.tsxconverting things to typescript- Made the
FieldPropsuse theT[]generic based on theArrayField'sTgeneric sinceformDatashould always be an array - There were many places where type safety checks were required along with custom casts to deal with
TvsT[]issues - Exported
ArrayFieldcast as aFieldto allow it to be used properly in theindex.ts
- Made the
- Refactored
BooleanField.jstoBooleanField.tsxconverting things to typescript - Refactored
MultiSchemaField.jstoMultiSchemaField.tsxconverting things to typescript - Refactored
NullField.jstoNullField.tsxconverting things to typescript - Refactored
NumberField.jstoNumberField.tsxconverting things to typescript as well as making it a stateless functional component withuseState()instead of a class - Refactored
ObjectField.jstoObjectField.tsxconverting things to typescript - Refactored
SchemaField.jstoSchemaField.tsxconverting things to typescript- Updated the code to deal with the
classNamesnow coming fromui:options, including updating tests accordingly adding a new one for the new case inside ofui:options
- Updated the code to deal with the
- Refactored
StringField.jstoStringField.tsxconverting things to typescript - Refactored
fields/index.jstofields/index.tsadding the proper type for the returned object - Updated
ArrayFieldTemplateto add the missingTandFgenerics required forgetUiOptions() - Updated
ObjectFieldTemplateto add theTandFgenerics ontogetUiOptions() - Refactored
fields/UnsupportedField.jstotemplates/UnsupportedField.tsxconverting things to typescript- Added this to
templates/index.tsasUnsupportedFieldTemplate - Also updated tests to use
templates.UnsupportedFieldTemplateinstead offields.UnsupportedField
- Added this to
- Updated
getDefaultRegistry()to remove the cast onfieldssince they are now properly typed
NOTE: This PR is stacked on top of #3001, but will be rebased once it merges
Checklist
- [ ] I'm updating documentation
- [ ] I've checked the rendering of the Markdown text I've added
- [x] I'm adding or updating code
- [ ] I'm adding a new feature
- [ ] I've updated the playground with an example use of the feature