Closed rt-joe closed 3 months ago
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
I would love to but I haven't been able to figure out the root issue. Our current workaround is to cast it to FastifyInstance
export const handler = fastifyLambda(app as unknown as FastifyInstance);
Not a major issue or blocker by any means.
More of an issue with the type provider itself, rather than aws-lambda-fastify
.
Assignability issues got fixed a while ago for the official type providers (fastify/fastify#4342 for context) - the zod type provider slipped through as it's a third party package that was only recently brought into the docs.
@rt-joe I've submitted a PR for the type provider, but it might take a while for you to reap the benefits considering that package hasn't been updated since January 2023. Since it's a very small change, you could consider patching the dependency (e.g. https://pnpm.io/cli/patch or https://www.npmjs.com/package/patch-package) with the changes from the linked PR.
If the package has not been updated, we could think of bringing it in the org if there is a need.
@rt-joe fix has been published, so you should be good to go once you upgrade to fastify-type-provider-zod@1.2.0
.
Worked like a charm! Much appreciated 🙏
Prerequisites
Fastify version
4.26.0
Plugin version
4.0.0
Node.js version
20.x
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
Sonoma 14.4
Description
When using Fastify type provider
ZodTypeProvider
from https://github.com/turkerdev/fastify-type-provider-zod we get the following type error when passing our app toawsLambdaFastify()
:Which boils down to
Type 'FastifyTypeProviderDefault' is not assignable to type 'ZodTypeProvider'.
I'm not sure if that is the actual error or a red herring.Our Fastify instance type is defined as:
I'm not sure if we're doing something wrong or fastify-type-provider-zod or fastify-aws-lambda. I can post the full non-truncated type error if that helps. Any help is appreciated!
Steps to Reproduce
Reproducible repo https://github.com/rt-joe/fastify-aws-lambda-zod-type-provider-type-error
With node v20 installed
Expected Behavior
No type error when using non default fastify type provider