fabian-hiller / valibot

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

"Issues" field of SafeParseResult shows up in ts autocomplete after the type was narrowed with `.success` #684

Closed dearlordylord closed 1 week ago

dearlordylord commented 1 week ago

It's a minor devex issue but I believe can be easily avoided; default expectation from libs is that the "errors" ("issues" in this case) field is not present after it's clear that the discriminated union is not a error-ish.

Screenshot 2024-06-29 at 5 17 35 PM

Maybe just removing https://github.com/fabian-hiller/valibot/blob/2d2e553b1ad18e0e68bcfb2870dd138c8987982d/library/src/methods/safeParse/types.ts#L33 solves it?

(thanks for the lib, it's so far really pleasant API to use)

fabian-hiller commented 1 week ago

This is intended. Our SafeParseResult type basically represents exactly the data that is returned and .issues is always present as you can see here.