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

Broken ErrorSchema type-definition #3239

Closed
4 tasks done
jcqvisser opened this issue Nov 14, 2022 · 1 comment · Fixed by #3307
Closed
4 tasks done

Broken ErrorSchema type-definition #3239

jcqvisser opened this issue Nov 14, 2022 · 1 comment · Fixed by #3307
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned

Comments

@jcqvisser
Copy link

Prerequisites

What theme are you using?

core

Version

5.0.0.beta.12

Current Behavior

Using TypeScript, when declaring a (presumaby) valid ErrorSchema object, compilation fails due to type errors.

Expected Behavior

ErrorSchema objects, such as those specified in the documentation, should be valid.

Steps To Reproduce

See sandbox: https://codesandbox.io/s/eloquent-cannon-sib4qg?file=/src/App.tsx

Environment

No response

Anything else?

No response

@jcqvisser jcqvisser added bug needs triage Initial label given, to be assigned correct labels and assigned labels Nov 14, 2022
@jcqvisser
Copy link
Author

Updating the ErrorSchema type as follows seems to work:

/** Type describing a recursive structure of `FieldErrors`s for an object with a non-empty set of keys */
declare type ErrorSchema<T = any> = FieldErrors & {
    [key in keyof T]?: ErrorSchema<T[key]>;
};

/** This seems to work */
declare type ErrorSchema<T = any> = FieldErrors | {
    [key in keyof T]?: ErrorSchema<T[key]>;
};

@jcqvisser jcqvisser mentioned this issue Nov 14, 2022
8 tasks
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Dec 21, 2022
…/utils

fix: rjsf-team#3239 by providing a new `ErrorSchemaBuilder` class in `@rjsf/utils`
- In `@rjsf/utils` added `ErrorSchemaBuilder` to facilitate building `ErrorSchema` objects without the need for fancy casting
  - Exported the new class as part of the main `index.js`
  - Added 100% unit tests
- In `@rjsf/validator-ajv6` and `@rjsf/validator-ajv8` updated the `toErrorSchema()` function to use the `ErrorSchemaBuilder` to simplify the implementation
  - Also updated the tests to use the `ErrorSchemaBuilder` to replace the expected values that required doing `as ErrorSchema` casting
- Updated the `utility-functions.md` file to document `ErrorSchemaBuilder`
- Updated the `CHANGELOG.md` accordingly for this fix as well as PR rjsf-team#3297
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Dec 22, 2022
…/utils

fix: rjsf-team#3239 by providing a new `ErrorSchemaBuilder` class in `@rjsf/utils`
- In `@rjsf/utils` added `ErrorSchemaBuilder` to facilitate building `ErrorSchema` objects without the need for fancy casting
  - Exported the new class as part of the main `index.js`
  - Added 100% unit tests
- In `@rjsf/validator-ajv6` and `@rjsf/validator-ajv8` updated the `toErrorSchema()` function to use the `ErrorSchemaBuilder` to simplify the implementation
  - Also updated the tests to use the `ErrorSchemaBuilder` to replace the expected values that required doing `as ErrorSchema` casting
- Updated the `utility-functions.md` file to document `ErrorSchemaBuilder`
- Updated the `CHANGELOG.md` accordingly for this fix as well as PR rjsf-team#3297
heath-freenome added a commit that referenced this issue Dec 22, 2022
…3307)

fix: #3239 by providing a new `ErrorSchemaBuilder` class in `@rjsf/utils`
- In `@rjsf/utils` added `ErrorSchemaBuilder` to facilitate building `ErrorSchema` objects without the need for fancy casting
  - Exported the new class as part of the main `index.js`
  - Added 100% unit tests
- In `@rjsf/validator-ajv6` and `@rjsf/validator-ajv8` updated the `toErrorSchema()` function to use the `ErrorSchemaBuilder` to simplify the implementation
  - Also updated the tests to use the `ErrorSchemaBuilder` to replace the expected values that required doing `as ErrorSchema` casting
- Updated the `utility-functions.md` file to document `ErrorSchemaBuilder`
- Updated the `CHANGELOG.md` accordingly for this fix as well as PR #3297
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this issue Jun 8, 2023
…/utils (rjsf-team#3307)

fix: rjsf-team#3239 by providing a new `ErrorSchemaBuilder` class in `@rjsf/utils`
- In `@rjsf/utils` added `ErrorSchemaBuilder` to facilitate building `ErrorSchema` objects without the need for fancy casting
  - Exported the new class as part of the main `index.js`
  - Added 100% unit tests
- In `@rjsf/validator-ajv6` and `@rjsf/validator-ajv8` updated the `toErrorSchema()` function to use the `ErrorSchemaBuilder` to simplify the implementation
  - Also updated the tests to use the `ErrorSchemaBuilder` to replace the expected values that required doing `as ErrorSchema` casting
- Updated the `utility-functions.md` file to document `ErrorSchemaBuilder`
- Updated the `CHANGELOG.md` accordingly for this fix as well as PR rjsf-team#3297
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this issue Jun 8, 2023
…/utils (rjsf-team#3307)

fix: rjsf-team#3239 by providing a new `ErrorSchemaBuilder` class in `@rjsf/utils`
- In `@rjsf/utils` added `ErrorSchemaBuilder` to facilitate building `ErrorSchema` objects without the need for fancy casting
  - Exported the new class as part of the main `index.js`
  - Added 100% unit tests
- In `@rjsf/validator-ajv6` and `@rjsf/validator-ajv8` updated the `toErrorSchema()` function to use the `ErrorSchemaBuilder` to simplify the implementation
  - Also updated the tests to use the `ErrorSchemaBuilder` to replace the expected values that required doing `as ErrorSchema` casting
- Updated the `utility-functions.md` file to document `ErrorSchemaBuilder`
- Updated the `CHANGELOG.md` accordingly for this fix as well as PR rjsf-team#3297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned
Projects
None yet
1 participant