Closed cruzdanilo closed 2 months ago
Thank you for creating this issue. I recommend that you change your schema. This will also fix this problem. However, I will investigate this problem and may change the current implementation.
You can try my code in this playground.
import * as v from 'valibot';
const Schema = v.object({
key: v.nullish(v.array(v.string()), ['default']),
});
type Input = v.InferInput<typeof Schema>;
type Output = v.InferOutput<typeof Schema>;
I agree. When an optional input is transformed to a non-optional value, the output type should reflect this information. I have improved the implementation and added new type test. Thanks for your feedback!
v0.40.0 is available 🚀
in v0.39, the output type of an object field with a transform is not working properly, returning the original type before the transformation. execution works as expected, but the typescript compiler fails. here is a reproduction example:
execution output:
tsc output:
i pushed this same repro to a git repo: https://github.com/cruzdanilo/repro-valibot-transform you can see this same output in the ci workflow log: https://github.com/cruzdanilo/repro-valibot-transform/actions/runs/10614474287/job/29420466950