@rjsf/utils 5.18.5 → 5.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts CHANGED
@@ -131,10 +131,12 @@ export type FieldId = {
131
131
  };
132
132
 
133
133
  /** Type describing a recursive structure of `FieldId`s for an object with a non-empty set of keys */
134
- export type IdSchema<T = any> = FieldId & {
135
- /** The set of ids for fields in the recursive object structure */
136
- [key in keyof T]?: IdSchema<T[key]>;
137
- };
134
+ export type IdSchema<T = any> = T extends GenericObjectType
135
+ ? FieldId & {
136
+ /** The set of ids for fields in the recursive object structure */
137
+ [key in keyof T]?: IdSchema<T[key]>;
138
+ }
139
+ : FieldId;
138
140
 
139
141
  /** Type describing a name used for a field in the `PathSchema` */
140
142
  export type FieldPath = {
@@ -143,10 +145,16 @@ export type FieldPath = {
143
145
  };
144
146
 
145
147
  /** Type describing a recursive structure of `FieldPath`s for an object with a non-empty set of keys */
146
- export type PathSchema<T = any> = FieldPath & {
147
- /** The set of names for fields in the recursive object structure */
148
- [key in keyof T]?: PathSchema<T[key]>;
149
- };
148
+ export type PathSchema<T = any> = T extends Array<infer U>
149
+ ? FieldPath & {
150
+ [i: number]: PathSchema<U>;
151
+ }
152
+ : T extends GenericObjectType
153
+ ? FieldPath & {
154
+ /** The set of names for fields in the recursive object structure */
155
+ [key in keyof T]?: PathSchema<T[key]>;
156
+ }
157
+ : FieldPath;
150
158
 
151
159
  /** The type for error produced by RJSF schema validation */
152
160
  export type RJSFValidationError = {