@@ -15,7 +15,7 @@ import {
15
15
RJSF_ADDITIONAL_PROPERTIES_FLAG ,
16
16
} from '../constants' ;
17
17
import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema' ;
18
- import { FormContextType , PathSchema , RJSFSchema , StrictRJSFSchema , ValidatorType } from '../types' ;
18
+ import { FormContextType , GenericObjectType , PathSchema , RJSFSchema , StrictRJSFSchema , ValidatorType } from '../types' ;
19
19
import getClosestMatchingOption from './getClosestMatchingOption' ;
20
20
import retrieveSchema from './retrieveSchema' ;
21
21
@@ -53,9 +53,9 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
53
53
}
54
54
}
55
55
56
- let pathSchema : PathSchema = {
56
+ let pathSchema : PathSchema < T > = {
57
57
[ NAME_KEY ] : name . replace ( / ^ \. / , '' ) ,
58
- } as PathSchema ;
58
+ } as PathSchema < T > ;
59
59
60
60
if ( ONE_OF_KEY in schema || ANY_OF_KEY in schema ) {
61
61
const xxxOf : S [ ] = ONE_OF_KEY in schema ? ( schema . oneOf as S [ ] ) : ( schema . anyOf as S [ ] ) ;
@@ -78,7 +78,7 @@ 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 > (
81
+ ( pathSchema as PathSchema < T [ ] > ) [ i ] = toPathSchemaInternal < T , S , F > (
82
82
validator ,
83
83
schemaItems [ i ] as S ,
84
84
`${ name } .${ i } ` ,
@@ -87,7 +87,7 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
87
87
_recurseList
88
88
) ;
89
89
} else if ( schemaAdditionalItems ) {
90
- pathSchema [ i ] = toPathSchemaInternal < T , S , F > (
90
+ ( pathSchema as PathSchema < T [ ] > ) [ i ] = toPathSchemaInternal < T , S , F > (
91
91
validator ,
92
92
schemaAdditionalItems as S ,
93
93
`${ name } .${ i } ` ,
@@ -101,7 +101,7 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
101
101
} ) ;
102
102
} else {
103
103
formData . forEach ( ( element , i : number ) => {
104
- pathSchema [ i ] = toPathSchemaInternal < T , S , F > (
104
+ ( pathSchema as PathSchema < T [ ] > ) [ i ] = toPathSchemaInternal < T , S , F > (
105
105
validator ,
106
106
schemaItems as S ,
107
107
`${ name } .${ i } ` ,
@@ -114,7 +114,7 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
114
114
} else if ( PROPERTIES_KEY in schema ) {
115
115
for ( const property in schema . properties ) {
116
116
const field = get ( schema , [ PROPERTIES_KEY , property ] ) ;
117
- pathSchema [ property ] = toPathSchemaInternal < T , S , F > (
117
+ ( pathSchema as PathSchema < GenericObjectType > ) [ property ] = toPathSchemaInternal < T , S , F > (
118
118
validator ,
119
119
field ,
120
120
`${ name } .${ property } ` ,
@@ -126,7 +126,7 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
126
126
) ;
127
127
}
128
128
}
129
- return pathSchema as PathSchema < T > ;
129
+ return pathSchema ;
130
130
}
131
131
132
132
/** Generates an `PathSchema` object for the `schema`, recursively
0 commit comments