Skip to content

fix: extend type from fastify/ajv-compiler for ajv field in fastify options #6223

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gianmarco27
Copy link

@gianmarco27 gianmarco27 commented Jun 17, 2025

As I was trying to add a custom validation pattern to Ajv through the ajv.onCreate property, as suggested in the fastify/ajv-compiler documentation, I incurred in a TS error for the FastifyServerOptions that although proxies the entire ajv property to the fastify/ajv-compiler builder method, does not expose correctly all of its properties into the typings.

This small change in the typings correctly exposes the available options, and should be future proof as the type is directly derived from the fastify/ajv-compiler types.

Checklist

@github-actions github-actions bot added typescript TypeScript related documentation Improvements or additions to documentation labels Jun 17, 2025
@gianmarco27 gianmarco27 reopened this Jun 17, 2025
@gianmarco27 gianmarco27 force-pushed the fix/ajv-options-typings branch 3 times, most recently from 19707c0 to 36a5cfd Compare June 17, 2025 21:35
@gianmarco27 gianmarco27 force-pushed the fix/ajv-options-typings branch from 36a5cfd to f6ba466 Compare June 17, 2025 21:45
@jean-michelet
Copy link
Member

Thanks for the PR!

Unfortunately, I don't know this part of the framework well enough to give quality feedback, so I will let an other contributor review your work.

But I think you should write a test to prove that onCreate integrates correctly with Fastify (I don't see any test on that regard in the core), and you should probably write typing tests too.

Typing tests are here:
https://github.com/fastify/fastify/tree/main/test/types

I am not sure where to write the integration test for onCreate, maybe here:
https://github.com/fastify/fastify/blob/main/test/schema-special-usage.test.js

@gianmarco27
Copy link
Author

Thank you for the quick feedback! I'll be on it ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation typescript TypeScript related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants