UNPKG

@snups/rjsf-utils

Version:
15 lines (14 loc) 766 B
import { RJSFSchema, StrictRJSFSchema } from './types.js'; /** Gets the type of a given `schema`. If the type is not explicitly defined, then an attempt is made to infer it from * other elements of the schema as follows: * - schema.const: Returns the `guessType()` of that value * - schema.enum: Returns `string` * - schema.properties: Returns `object` * - schema.additionalProperties: Returns `object` * - schema.patternProperties: Returns `object` * - type is an array with a length of 2 and one type is 'null': Returns the other type * * @param schema - The schema for which to get the type * @returns - The type of the schema */ export default function getSchemaType<S extends StrictRJSFSchema = RJSFSchema>(schema: S): string | string[] | undefined;