Conversation
|
@jorisre I believe I made some progress on the types here, in #755 and in react-hook-form/react-hook-form#12664 Let me know how it looks to you |
|
Size Change: +1.72 kB (+3.17%) Total Size: 55.8 kB
ℹ️ View Unchanged
|
kotarella1110
left a comment
There was a problem hiding this comment.
LGTM! Appreciate your hard work!
Appreciate your help, thanks again! |
bluebill1049
left a comment
There was a problem hiding this comment.
Thanks everyone! Huge effort @jorisre
The base branch was changed.
|
🎉 This PR is included in version 5.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
| "license": "MIT", | ||
| "peerDependencies": { | ||
| "react-hook-form": "^7.0.0", | ||
| "react-hook-form": "7.55.0", |
There was a problem hiding this comment.
Should this be locked to version 7.55.0?
| "react-hook-form": "7.55.0", | |
| "react-hook-form": "^7.55.0", |
There was a problem hiding this comment.
Why do we switch from arktype native implementation to standard-schema? And why not all standard-schema-compatible resolvers follow this approach?
There was a problem hiding this comment.
Also, using this approach will lead to the resolver failing to infer the type from the schema, unless the user specifically installs @standard-schema/spec as their dependency
There was a problem hiding this comment.
apologize for mentioning you guys @jorisre @bluebill1049 @kotarella1110
There was a problem hiding this comment.
We switched to standard-schema from the native arktype implementation because type inference in Arktype wasn't working as expected. But if you've found a solid solution, we're happy to review a PR :)
1. Remove `/\\.` from `vitest.config.ts`. This was necessary to fix the error `No test files found`. This can also be fixed by updating Vitest to version 4, but this has a change to how snapshots are stored. See [the migration guide](https://vitest.dev/guide/migration.html#changes-to-mocking). All of the tests are found by removing `/\\.`, so the Vitest upgrade is better in a later PR. 1. Inlined `z` in `vitest.config.ts` to spy on `parse()` from `zod/v4/core`. Without this, a `TypeError: Cannot redefine property: parse` error occurs. 1. Change `bun test` to `bun run test` in CONTRIBUTING.md. `bun test` runs Bun's native test runner, not the `test` script. 1. Add `Test` stage to `.github/workflows/main.yml`. It was removed in [this PR](react-hook-form#699) and the tests haven't been running in CI. 1. Fix failing tests Notes: 1. All * Fixed tests that called `useForm` outside of a component. This fixed the errors `Error: Invalid hook call. Hooks can only be called inside of the body of a function component.` and `TypeError: Cannot read properties of null (reading 'useRef')`. 1. Arktype * [This PR](react-hook-form#753) changed from directly calling Arktype to using standard schema. Part of this transition was changing `type: error.code` to `type: ''` (because `error.code` is not part of the standard schema). This required an update to the snapshot. 1. Superstruct * Fix validation of schemas that perform coercion (`{ coerce: true }` must be passed in) * Added additional overload for type definition `superstructResolver` that improves handling of coerced schemas (This fixes a type error with the form values). * Fix definition of coercion schema so that it correctly converts from number to string * As mentioned in [this issue](ianstormtaylor/superstruct#1159), there is no way to infer the input type of a coerced schema. A [separate PR](ianstormtaylor/superstruct#1181) would be necessary. Some of the type inference tests have been changed to manually provide the input type (this enables `watch` to return the correct value for a coerced schema). 1. Typeschema * The `for` loop was looping through the `schemaErrors` variable, but the current error was based on the `typeschemaErrors[0]` variable. This caused only the first error to be returned. * Change from spying on `typeschema.validate` to watching `schema["~standard"]` 1. Zod * Fixed Zod tests that spied on `schema.parse()` instead of `z4.parse()` * Added missing snapshots
This PR implements typed Input/Output interfaces for resolvers, which needs react-hook-form/react-hook-form#12638
Next steps will involve extending this implementation to all applicable resolver modules.
Note: This PR will fail until the release of react-hook-form/react-hook-form#12638
Fixes #743