-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
TypeScript reports errors when union type passed as Body to RouteGeneric since Fastify 4 #4063
Comments
I ran into this and investigated a bit (didn't realize someone else had made an issue). Here's what I found: Firstly, This then gets moved into fastify/types/type-provider.d.ts Lines 34 to 35 in 4361770
See, What is there to do? Well, checking StackOverflow, I find that something like tl;dr Why is If that is intentional, then |
Thanks for reporting! Would you like to work on a PR with a fix? I'm not sure if your proposed solution is ok, however it mostly depends if it breaks any other tests. |
I believe I fix this in #4076 |
Prerequisites
Fastify version
4.1.0
Plugin version
No response
Node.js version
18.x
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.3
Description
Hi, I came across the following problem after updating to 4.x.
Body
property of request gets resolved tounknown
instead of{ filters?: { ids: string[] } } | null
. Use-case: we have some routes that optionally accept body using ajv'sanyOf
keyword. It used to work in Fastify 3.Fastify 4:
vs.
Fastify 3:
Steps to Reproduce
This snippet can be used to reproduce the problem:
Expected Behavior
body
type gets resolved to{ filters?: { ids: string[] } } | null
instead of unknown.The text was updated successfully, but these errors were encountered: