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

Valibot toTypedSchema throws type error Argument of type ObjectSchema is not assignable to parameter of type BaseSchema #4951

Open
2 of 5 tasks
artemosuskyi opened this issue Nov 22, 2024 · 6 comments

Comments

@artemosuskyi
Copy link

artemosuskyi commented Nov 22, 2024

What happened?

Code snippet directly copied from documentation causes type error on the screenshot.
Package versions:

"@vee-validate/valibot": "^4.14.7",
"valibot": "^1.0.0-beta.8",
"vee-validate": "^4.14.7",

image

Reproduction steps

No response

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

No response

Demo link

https://stackblitz.com/edit/vee-validate-v4-radio-ssadza?file=src%2FApp.vue (see the console output)

Code of Conduct

@slyduda
Copy link

slyduda commented Nov 22, 2024

the readonly property ~validate in the BaseSchema type has changed in valibot to ~run, probably sometime after their big 0.31.0 api migration.

(i just ran into this issue too)

seems like types are correct in the latest main, but maybe an up to date release has not been made.

@slyduda
Copy link

slyduda commented Nov 22, 2024

if you or anyone who needs this fixed before the maintainers get to it i'd suggest the following:

  1. clone this project as a sibling folder of your current project
  2. add this to dependencies:
    "@vee-validate/valibot": "file:../vee-validate/packages/valibot",
  3. npm install -g pnpm if you don't have pnpm
  4. pnpm install on the cloned project
  5. pnpm build on the cloned project
  6. then run install on your own project and you should be good to code away

@logaretm
Copy link
Owner

logaretm commented Nov 23, 2024

I will tag the latest soon after I test a few things around valibot and i18n. Thank you @slyduda for posting a workaround.

@TArch64
Copy link

TArch64 commented Nov 24, 2024

As a quick workaround without cloning a repo this also works. Types isnt corrent but at least no exception in runtime

// @ts-expect-error
// eslint-disable-next-line vue/no-mutating-props
props.schema['~validate'] = props.schema['~run'];

@dipbhi
Copy link

dipbhi commented Nov 29, 2024

if you or anyone who needs this fixed before the maintainers get to it i'd suggest the following:

  1. clone this project as a sibling folder of your current project
  2. add this to dependencies:
    "@vee-validate/valibot": "file:../vee-validate/packages/valibot",
  3. npm install -g pnpm if you don't have pnpm
  4. pnpm install on the cloned project
  5. pnpm build on the cloned project
  6. then run install on your own project and you should be good to code away

This workaround doesn't work because pnpm install itself errors out.

Rolling back to [email protected] and [email protected] works.

@slyduda
Copy link

slyduda commented Dec 14, 2024

any update on this? if not, any way we can help?

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

No branches or pull requests

5 participants