@@ -42,21 +42,21 @@ const ARRAY_PROPERTIES = [
42
42
*/
43
43
export function getSchemaType ( node , data ) {
44
44
const dataType = getTypeOf ( data ) ;
45
- // @ts -expect-error boolean schema true
46
- if ( node . schema === true ) {
45
+ const schema = node . schema ;
46
+ if ( schema === true ) {
47
47
return SCHEMA_TYPES . includes ( dataType ) ? dataType : undefined ;
48
48
}
49
49
// boolean schema false or invalid schema
50
- if ( ! isObject ( node . schema ) ) {
50
+ if ( ! isObject ( schema ) ) {
51
51
return undefined ;
52
52
}
53
- const schemaType = node . schema . type ;
53
+ const schemaType = schema . type ;
54
54
// type: []
55
55
if ( Array . isArray ( schemaType ) ) {
56
56
if ( schemaType . includes ( dataType ) ) {
57
57
return dataType ;
58
58
}
59
- const defaultType = getTypeOf ( node . schema . default ) ;
59
+ const defaultType = getTypeOf ( schema . default ) ;
60
60
if ( schemaType . includes ( defaultType ) ) {
61
61
return defaultType ;
62
62
}
@@ -67,13 +67,13 @@ export function getSchemaType(node, data) {
67
67
return schemaType ;
68
68
}
69
69
// type: undefined, enum: []
70
- if ( Array . isArray ( node . schema . enum ) ) {
71
- const schemaEnum = node . schema . enum ;
70
+ if ( Array . isArray ( schema . enum ) ) {
71
+ const schemaEnum = schema . enum ;
72
72
const enumSchemaType = schemaEnum . map ( ( value ) => getTypeOf ( value ) ) . filter ( ( p , i , l ) => l . indexOf ( p ) === i ) ;
73
73
if ( enumSchemaType . includes ( dataType ) ) {
74
74
return dataType ;
75
75
}
76
- const defaultType = getTypeOf ( node . schema . default ) ;
76
+ const defaultType = getTypeOf ( schema . default ) ;
77
77
if ( enumSchemaType . includes ( defaultType ) ) {
78
78
return defaultType ;
79
79
}
0 commit comments