ValidatorType and customizeValidator() take the schema as their first type argument
Detect
- Your code passes a form data type to
customizeValidator<MyData>()orValidatorType<MyData>. - The type checker reports one of these, depending on
MyData:TS2559: Type 'MyData' has no properties in common with type 'StrictRJSFSchema'at the declaration, whenMyDatashares no keys withJSONSchema7.TS2344: Type 'MyData' does not satisfy the constraint 'StrictRJSFSchema'at the declaration, when a shared key has a conflicting type.TS2322: Type 'StrictRJSFSchema' is not assignable to type 'MyData'on theschemaprop of aFormthat infers its types from the validator, orTS2741: Property '…' is missing in type 'StrictRJSFSchema' but required in type 'MyData'whenMyDataalso has a required key thatJSONSchema7lacks. This happens when the declaration compiles with the schema typed asMyData, such as for atitle: string.
- A
Form<MyData>may report nothing, since the validator's methods are checked bivariantly. Search your code for the type argument.
Change
ValidatorType<S, F> puts the form data type on validateFormData<T>(), since a validator checks data of any shape against a schema. The default export of @rjsf/validator-ajv8, @rjsf/validator-ata and @rjsf/validator-cfworker fits every Form, and customizeValidator() takes only <S, F>. In every case, drop the type argument:
-const validator = customizeValidator<MyData>();
+const validator = customizeValidator();
<Form<MyData> schema={schema} validator={validator} />
Verify
- No
customizeValidator<…>()orValidatorType<…>in your code names a form data type. - The type checker reports none of the errors above.