Skip to content

Commit

Permalink
TypeScript fix thanks to @tim-hellhake
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrancis committed Aug 23, 2024
1 parent 41f2776 commit 181cbf0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions static/js/schema-form/schema-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ export function withDependentSchema(
schema = mergeSchemas(schema, dependentSchema);
return typeof oneOf === 'undefined'
? schema
: withExactlyOneSubschema(schema, definitions, formData, dependencyKey, <unknown[]>oneOf);
: withExactlyOneSubschema(schema, definitions, formData, dependencyKey, <JsonSchema[]>oneOf);
}

export function withExactlyOneSubschema(
schema: Record<string, unknown>,
definitions: Record<string, unknown>,
formData: Record<string, unknown>,
dependencyKey: string,
oneOf: unknown[]
oneOf: JsonSchema[]
): Record<string, unknown> {
if (!Array.isArray(oneOf)) {
throw new Error(`invalid oneOf: it is some ${typeof oneOf} instead of an array`);
Expand Down Expand Up @@ -432,3 +432,11 @@ export function getOptionsList(schema: Record<string, unknown>): Record<string,
});
}
}

interface JsonSchema {
properties: Record<string, PropertySchema>
}

interface PropertySchema {
type: string
}

0 comments on commit 181cbf0

Please sign in to comment.