Closed morinokami closed 1 month ago
Thank you for creating this issue. Can you send me the before, after and expected code? Here is a template:
// Before
...
// After
...
// Expected
...
@fabian-hiller Sure! The schemas in my code are excerpts from the migration document, so the expected code is the same as described there. Here is the filled-in template:
// Before
import * as v from 'valibot';
const Schema = v.string([v.email()]);
const ObjectSchema = v.object({ key: v.string() }, v.null_());
const TupleSchema = v.tuple([v.string()], v.null_());
const LooseObjectSchema = v.object({ key: v.string() }, v.unknown());
const LooseTupleSchema = v.tuple([v.string()], v.unknown());
const StrictObjectSchema = v.object({ key: v.string() }, v.never());
const StrictTupleSchema = v.tuple([v.string()], v.never());
// After
import * as v from 'valibot';
const Schema = v.pipe(v.string(), v.email());
const ObjectSchema = v.object({ key: v.string() }, v.null_());
const TupleSchema = v.tuple([v.string()], v.null_());
const LooseObjectSchema = v.object({ key: v.string() }, v.unknown());
const LooseTupleSchema = v.tuple([v.string()], v.unknown());
const StrictObjectSchema = v.object({ key: v.string() }, v.never());
const StrictTupleSchema = v.tuple([v.string()], v.never());
// Expected
import * as v from 'valibot';
const Schema = v.pipe(v.string(), v.email());
const ObjectSchema = v.objectWithRest({ key: v.string() }, v.null_());
const TupleSchema = v.tupleWithRest([v.string()], v.null_());
const LooseObjectSchema = v.looseObject({ key: v.string() });
const LooseTupleSchema = v.looseTuple([v.string()]);
const StrictObjectSchema = v.strictObject({ key: v.string() });
const StrictTupleSchema = v.strictTuple([v.string()]);
Thank you very much! I am aware of these missing parts, but unfortunately I do not have time to fix them at the moment. Are you familiar with GritQL?
Unfortunately, I am not familiar with GritQL, so I think I am unable to help with the fixes. Sorry for not being able to assist 🥲
I ping @morgante. Maybe he has time and is motivated to fix it.
Hi @morinokami - sorry for the mistake! Did you try the other codemod?
I took a crack at it: https://github.com/fabian-hiller/valibot/pull/625/files
Hi, I tried the automatic upgrade command for v0.31.0 as described here, but it seems to only work well with specific patterns when using Grit. When I run the command
npx @getgrit/cli apply github.com/fabian-hiller/valibot#migrate_to_v0_31_0
on the following code, only the first schema is converted, and the rest are not.The command output is as follows: