Skip to content

Commit

Permalink
Merge branch 'master' into fix/fastify.use-types
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmukuthu committed Jun 18, 2020
2 parents baa0e8d + 68f1ac6 commit e534636
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion test/types/instance.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fastify, { FastifyInstance } from '../../fastify'
import fastify, { FastifyError, FastifyInstance } from '../../fastify';
import { expectAssignable, expectType } from 'tsd'
import { IncomingMessage, ServerResponse } from 'http'

Expand All @@ -16,3 +16,10 @@ expectAssignable<FastifyInstance>(server.addSchema({

expectType<unknown>(server.use(() => {}))
expectType<unknown>(server.use('/foo', () => {}))

server.setErrorHandler((function (error, request, reply) {
expectAssignable<FastifyInstance>(this)
}))

function errorHandler(this: FastifyInstance, error: FastifyError) {}
server.setErrorHandler(errorHandler)
2 changes: 1 addition & 1 deletion types/instance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export interface FastifyInstance<
* Set a function that will be called whenever an error happens
*/
setErrorHandler(
handler: (error: FastifyError, request: FastifyRequest<RawServer, RawRequest>, reply: FastifyReply<RawServer, RawRequest, RawReply>) => void
handler: (this: FastifyInstance<RawServer, RawRequest, RawReply, Logger>, error: FastifyError, request: FastifyRequest<RawServer, RawRequest>, reply: FastifyReply<RawServer, RawRequest, RawReply>) => void
): void;

/**
Expand Down

0 comments on commit e534636

Please sign in to comment.