fabian-hiller / valibot

The modular and type safe schema library for validating structural data 🤖
https://valibot.dev
MIT License
6.35k stars 204 forks source link

nested prop of flattened issues is typed as '{} | undefined' when object schema is piped to forward #793

Closed istonikula closed 3 months ago

istonikula commented 3 months ago

When not using pipe + forward, the nested prop with the same object schema is typed correctly. Example linked below, am I doing something wrong? With 0.0.30 api (from which I'm trying to migrate), the same type of structure (v.object({...}, [v.forward[v.custom(...)]]) the types worked as expected.

https://valibot.dev/playground/?code=JYWwDg9gTgLgBAKjgQwM5wG5wGZQiOAcg2QBtgAjCGQgbgCh6B6JuAYwgDtV4BlNgBYBTEMjgBeTADoIFAFZC2MABQBvZqzhwRyYKQBc0sMDBDlGKTyjBOAc2UBKADTSdex841a4YNKgDu0AAmhhbGpuaWMNZ2ji4WIDYAMkJ2MALKABwOnixwAL4ODPQc3HyCOhJGJmYWsgpKavRabgbVERZWNvbOrqLuOU7NPn6BUCHttVExPfFSiZwpaRnZnoVz2ND+yOORFWwA1srKNmAArjAOEgB8cKcXUq0S4pL3MFK+qAHBvQDahJ9vuNCABdHLFUo8OBQISoM6keCSTrIbBCAAKO1QZn4wlELnULX6bUIcmQnCEAAEhAAPZDgUhCKQcECEIZaQFjCaEACMACYAMwAFgArAA2ADsmVZ9EKxXowGwcGUMLhCKkwC+Z1hVwJcDywhhOFIyBgAFEoHgoKgpOSeEIgnABGg4DAAJ6mOCqfJwAA+cDOnCCQmwNntcH8wk4cFQFVEjud4SEcAA1DgtjsgsNIfBsMazRboOgkVJcyaYKkADxu0wQRU4nTXZWw+HvDVw7W0OAy+hAA

fabian-hiller commented 3 months ago

Thank you for reporting this. Unfortunately there is an unexpected behavior in our IssueDotPath type when a schema is wrapped in a pipe. I will release a fix with the next version.

fabian-hiller commented 3 months ago

This is fixed in v0.39.0