Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional properties inferred as { prop?: <type> | undefined } #434

Open
DeadOce4n opened this issue Feb 20, 2023 · 0 comments
Open

Optional properties inferred as { prop?: <type> | undefined } #434

DeadOce4n opened this issue Feb 20, 2023 · 0 comments

Comments

@DeadOce4n
Copy link

Hi, I recently started using Papr in one of my projects and so far I've been liking it a lot! But recently I came across an issue: the project is an API built with Fastify, and I use TypeBox as a validator, which infers optional properties as prop?: <type>, whereas Papr infers optional properties as prop?: <type> | undefined, this union type makes assigning a Papr document to a Fastify response schema when using TypeBox as a type provider impossible without extra work.

Captura de pantalla 2023-02-20 a la(s) 14 13 21

Captura de pantalla 2023-02-20 a la(s) 14 13 56

Captura de pantalla 2023-02-20 a la(s) 14 19 24

Is there a recommended way to handle something like this? The only two workarounds I've found is to define an optional property as a union with undefined at the validator level (allowing explicitly passing an undefined as a value), which seems very hacky, and disabling ts-config's exactOptionalPropertyTypes, which I guess is not too bad but still, if theres an option which doesn't involve touching the compiler's settings it would be perfect. Thanks in advance, and great work btw!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant