@@ -78,52 +78,49 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
78
78
if ( Array . isArray ( schemaItems ) ) {
79
79
formData . forEach ( ( element , i : number ) => {
80
80
if ( schemaItems [ i ] ) {
81
- pathSchema [ i ] = toPathSchemaInternal < T , S , F > (
82
- validator ,
83
- schemaItems [ i ] as S ,
84
- `${ name } .${ i } ` ,
85
- rootSchema ,
86
- element ,
87
- _recurseList
88
- ) ;
81
+ ( pathSchema as { [ key in keyof PathSchema < T > ] : PathSchema < T > } ) [ i as keyof PathSchema < T > ] =
82
+ toPathSchemaInternal < T , S , F > (
83
+ validator ,
84
+ schemaItems [ i ] as S ,
85
+ `${ name } .${ i } ` ,
86
+ rootSchema ,
87
+ element ,
88
+ _recurseList
89
+ ) ;
89
90
} else if ( schemaAdditionalItems ) {
90
- pathSchema [ i ] = toPathSchemaInternal < T , S , F > (
91
- validator ,
92
- schemaAdditionalItems as S ,
93
- `${ name } .${ i } ` ,
94
- rootSchema ,
95
- element ,
96
- _recurseList
97
- ) ;
91
+ ( pathSchema as { [ key in keyof PathSchema < T > ] : PathSchema < T > } ) [ i as keyof PathSchema < T > ] =
92
+ toPathSchemaInternal < T , S , F > (
93
+ validator ,
94
+ schemaAdditionalItems as S ,
95
+ `${ name } .${ i } ` ,
96
+ rootSchema ,
97
+ element ,
98
+ _recurseList
99
+ ) ;
98
100
} else {
99
101
console . warn ( `Unable to generate path schema for "${ name } .${ i } ". No schema defined for it` ) ;
100
102
}
101
103
} ) ;
102
104
} else {
103
105
formData . forEach ( ( element , i : number ) => {
104
- pathSchema [ i ] = toPathSchemaInternal < T , S , F > (
105
- validator ,
106
- schemaItems as S ,
107
- `${ name } .${ i } ` ,
108
- rootSchema ,
109
- element ,
110
- _recurseList
111
- ) ;
106
+ ( pathSchema as { [ key in keyof PathSchema < T > ] : PathSchema < T > } ) [ i as keyof PathSchema < T > ] =
107
+ toPathSchemaInternal < T , S , F > ( validator , schemaItems as S , `${ name } .${ i } ` , rootSchema , element , _recurseList ) ;
112
108
} ) ;
113
109
}
114
110
} else if ( PROPERTIES_KEY in schema ) {
115
111
for ( const property in schema . properties ) {
116
112
const field = get ( schema , [ PROPERTIES_KEY , property ] ) ;
117
- pathSchema [ property ] = toPathSchemaInternal < T , S , F > (
118
- validator ,
119
- field ,
120
- `${ name } .${ property } ` ,
121
- rootSchema ,
122
- // It's possible that formData is not an object -- this can happen if an
123
- // array item has just been added, but not populated with data yet
124
- get ( formData , [ property ] ) ,
125
- _recurseList
126
- ) ;
113
+ ( pathSchema as { [ key in keyof PathSchema < T > ] : PathSchema < T > } ) [ property as keyof PathSchema < T > ] =
114
+ toPathSchemaInternal < T , S , F > (
115
+ validator ,
116
+ field ,
117
+ `${ name } .${ property } ` ,
118
+ rootSchema ,
119
+ // It's possible that formData is not an object -- this can happen if an
120
+ // array item has just been added, but not populated with data yet
121
+ get ( formData , [ property ] ) ,
122
+ _recurseList
123
+ ) ;
127
124
}
128
125
}
129
126
return pathSchema as PathSchema < T > ;
0 commit comments