mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
[yup] Added better definition for yup's SchemaDescription.fields (#40822)
* Added better definitions for SchemaDescription.fields * indentation fix
This commit is contained in:
18
types/yup/index.d.ts
vendored
18
types/yup/index.d.ts
vendored
@@ -351,12 +351,28 @@ export interface TestOptions<P extends Record<string, any> = {}, R = any> {
|
||||
exclusive?: boolean;
|
||||
}
|
||||
|
||||
export interface SchemaFieldRefDescription {
|
||||
type: 'ref';
|
||||
key: string;
|
||||
}
|
||||
|
||||
export interface SchemaFieldInnerTypeDescription extends Pick<
|
||||
SchemaDescription, Exclude<keyof SchemaDescription, 'fields'>
|
||||
> {
|
||||
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<string, SchemaFieldDescription>;
|
||||
}
|
||||
|
||||
// ValidationError works a lot more like a class vs. a constructor
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user