diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts
index aabeb3443e..b2939d050f 100644
--- a/types/yup/index.d.ts
+++ b/types/yup/index.d.ts
@@ -351,12 +351,28 @@ export interface TestOptions
= {}, R = any> {
exclusive?: boolean;
}
+export interface SchemaFieldRefDescription {
+ type: 'ref';
+ key: string;
+}
+
+export interface SchemaFieldInnerTypeDescription extends Pick<
+ SchemaDescription, Exclude
+> {
+ innerType?: SchemaFieldDescription;
+}
+
+export type SchemaFieldDescription =
+ | SchemaDescription
+ | SchemaFieldRefDescription
+ | SchemaFieldInnerTypeDescription;
+
export interface SchemaDescription {
type: string;
label: string;
meta: object;
tests: Array<{ name: string; params: object }>;
- fields: object;
+ fields: Record;
}
// ValidationError works a lot more like a class vs. a constructor
diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts
index f1b2898749..af6fa3fd83 100644
--- a/types/yup/yup-tests.ts
+++ b/types/yup/yup-tests.ts
@@ -449,7 +449,32 @@ const description: SchemaDescription = {
{ name: 'test1', params: {} },
{ name: 'test2', params: {} },
],
- fields: { key: 'value' },
+ fields: {
+ refField: {
+ type: 'ref',
+ key: 'value',
+ },
+ noSubField: {
+ type: 'type',
+ label: 'label',
+ meta: { key: 'value' },
+ tests: [],
+ },
+ subField: {
+ type: 'type',
+ label: 'label',
+ meta: { key: 'value' },
+ tests: [],
+ fields: { key: { type: 'ref', key: 'value' } }
+ },
+ withInnerType: {
+ type: 'type',
+ label: 'label',
+ meta: { key: 'value' },
+ tests: [],
+ innerType: { type: 'ref', key: 'value' }
+ },
+ },
};
const testOptions: TestOptions = {