import fastify, { FastifyRequest, FastifyReply, preHandlerHookHandler, FastifyInstance } from 'fastify'; import fastifyAuth from '../auth' import { expectType } from 'tsd'; const app = fastify(); type Done = (error?: Error) => void app.register(fastifyAuth).after((err) => { app.auth([ (request, reply, done) => { expectType(request) expectType(reply) expectType(done) }, ], {relation: 'or'}); app.auth([ (request, reply, done) => { expectType(request) expectType(reply) expectType(done) }, ], {run: 'all'}); app.auth([ (request, reply, done) => { expectType(request) expectType(reply) expectType(done) }, ]); app.auth([ function (request, reply, done) { expectType(this) }, ]); const auth = app.auth([(request, reply, done) => {}]); expectType(auth); app.get('/secret', {preHandler: auth}, (request, reply) => {}); app.get('/private', {preHandler: [auth]}, (request, reply) => {}); });