Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing ErrorSchema claims subsequent fields 'are not assignable' #4338

Open
4 tasks done
justinwrobel opened this issue Oct 17, 2024 · 1 comment
Open
4 tasks done
Labels

Comments

@justinwrobel
Copy link

justinwrobel commented Oct 17, 2024

Prerequisites

What theme are you using?

utils

Version

5.21.2

Current Behavior

Typing ErrorSchema claims subsequent fields 'are not assignable'. The following is the relevant code and the full error message

Relevant code:

const userFormErrors: ErrorSchema<{ username: string }>=...

Error message:

Type '{ __errors: string[]; }' is not assignable to type 'ErrorSchema<string>'.
  Type '{ __errors: string[]; }' is not assignable to type 'string'.

Full example is at https://codesandbox.io/p/sandbox/confident-framework-34wv6s

Expected Behavior

ErrorSchema should not throw errors when Typed

Steps To Reproduce

See full example at https://codesandbox.io/p/sandbox/confident-framework-34wv6s

The following error is visible in the "problems" pane

Type '{ __errors: string[]; }' is not assignable to type 'ErrorSchema<string>'.
  Type '{ __errors: string[]; }' is not assignable to type 'string'.

Environment

https://codesandbox.io/p/sandbox/confident-framework-34wv6s

Anything else?

No response

@justinwrobel justinwrobel added bug needs triage Initial label given, to be assigned correct labels and assigned labels Oct 17, 2024
@justinwrobel justinwrobel changed the title <title> Typing ErrorSchema claims subsequent fields 'are not assignable' Oct 17, 2024
@heath-freenome heath-freenome added utils Related to @rjsf/utils wontfix typescript and removed needs triage Initial label given, to be assigned correct labels and assigned labels Oct 18, 2024
@heath-freenome
Copy link
Member

@justinwrobel The error schema typing is pretty strange given it's recursive nature. If you use the ErrorSchemaBuilder to create your ErrorSchema instance then you can avoid these issues that can be caused by trying to hand-code one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants