Skip to content

Commit

Permalink
Fix IdSchema and PathSchema types
Browse files Browse the repository at this point in the history
  • Loading branch information
solimant authored May 19, 2024
1 parent eec280a commit 721cf22
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ export type FieldId = {
};

/** Type describing a recursive structure of `FieldId`s for an object with a non-empty set of keys */
export type IdSchema<T = any> = FieldId & {
/** The set of ids for fields in the recursive object structure */
[key in keyof T]?: IdSchema<T[key]>;
};
export type IdSchema<T = any> = T extends GenericObjectType
? FieldId & {
/** The set of ids for fields in the recursive object structure */
[key in keyof T]?: IdSchema<T[key]>;
}
: FieldId;

/** Type describing a name used for a field in the `PathSchema` */
export type FieldPath = {
Expand All @@ -143,10 +145,12 @@ export type FieldPath = {
};

/** Type describing a recursive structure of `FieldPath`s for an object with a non-empty set of keys */
export type PathSchema<T = any> = FieldPath & {
/** The set of names for fields in the recursive object structure */
[key in keyof T]?: PathSchema<T[key]>;
};
export type PathSchema<T = any> = T extends GenericObjectType
? FieldPath & {
/** The set of names for fields in the recursive object structure */
[key in keyof T]?: PathSchema<T[key]>;
}
: FieldPath;

/** The type for error produced by RJSF schema validation */
export type RJSFValidationError = {
Expand Down

0 comments on commit 721cf22

Please sign in to comment.