fabian-hiller / valibot

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

Proposal to Make Prettify Type in Valibot Overridable for Better Developer Control #728

Open devcaeg opened 1 month ago

devcaeg commented 1 month ago

The Prettify type is an internal type used by Valibot. It acts as a “trick” in TypeScript to “unroll” the types, making them easier for the end user to understand. However, the Prettify type can cause issues because it “decomposes” the types, potentially leading to uncommon errors in TypeScript. Therefore, I propose that this type be declared in a declare module 'valibot' block. This would allow developers to override the type in their projects if, for example, they want to negate its effects.

declare module 'valibot/types' {
    export type Prettify<TObject> = {
        [TKey in keyof TObject]: TObject[TKey];
    } & {};
}
fabian-hiller commented 1 month ago

Thanks for bringing this up! I agree and will look into it, but it may take some time as other things have a higher priority for me right now.

devcaeg commented 1 month ago

@fabian-hiller

I just created a pull request, feel free to review it when you have time. Thank you very much!