Skip to content

Commit

Permalink
fix: types to support Ajv plugins with options (#3601)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pietro Verdile committed Jan 16, 2022
1 parent ae3320d commit ee795d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fastify.d.ts
Expand Up @@ -144,7 +144,7 @@ export type FastifyServerOptions<
return503OnClosing?: boolean,
ajv?: {
customOptions?: AjvOptions,
plugins?: Function[]
plugins?: (Function | [Function, unknown])[]
},
frameworkErrors?: <RequestGeneric extends RequestGenericInterface = RequestGenericInterface>(
error: FastifyError,
Expand Down
16 changes: 16 additions & 0 deletions test/types/fastify.test-d.ts
Expand Up @@ -178,6 +178,22 @@ expectAssignable<FastifyInstance>(fastify({
plugins: [() => { }]
}
}))
expectAssignable<FastifyInstance>(fastify({
ajv: {
customOptions: {
nullable: false
},
plugins: [[() => { }, 'keyword']]
}
}))
expectAssignable<FastifyInstance>(fastify({
ajv: {
customOptions: {
nullable: false
},
plugins: [[() => { }, ['keyword1', 'keyword2']]]
}
}))
expectAssignable<FastifyInstance>(fastify({ frameworkErrors: () => { } }))
expectAssignable<FastifyInstance>(fastify({
rewriteUrl: (req) => req.url === '/hi' ? '/hello' : req.url!
Expand Down

0 comments on commit ee795d3

Please sign in to comment.