Skip to content

OliverRM/sentry-fastify-type-error

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Error report

Description

Sentry.setupFastifyErrorHandler throws the following TypeScript error after enabling TypeScript feature exactOptionalPropertyTypes:

error TS2345: Argument of type 'FastifyInstance<Server<typeof IncomingMessage, typeof ServerResponse>, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault> & PromiseLike<...> & { ...; }' is not assignable to parameter of type 'FastifyInstance'.
  The types of 'register(...).addHook' are incompatible between these types.
    Type '{ <RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = unknown, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyBaseLogger = FastifyBaseLogger, Fn extends onRequestAsyncHookHandler<...> | onRequestHookHandler<...> = onRequestHookHandler<...>>(name: "onReque...' is not assignable to type '{ (hook: string, handler: HandlerOriginal): FastifyInstance; (hook: "onError", handler: (request: FastifyRequest, reply: FastifyReply, error: Error) => void): FastifyInstance; (hook: "onRequest", handler: (request: FastifyRequest, reply: FastifyReply) => void): FastifyInstance; }'.
      Types of parameters 'hook' and 'handler' are incompatible.
        Type 'HandlerOriginal' is not assignable to type 'onRequestAsyncHookHandler<Server<typeof IncomingMessage, typeof ServerResponse>, IncomingMessage, ServerResponse<IncomingMessage>, ... 4 more ..., any> | onRequestHookHandler<...>'.
          Type '(request: FastifyRequest, reply: FastifyReply, done: HookHandlerDoneFunction) => Promise<void>' is not assignable to type 'onRequestAsyncHookHandler<Server<typeof IncomingMessage, typeof ServerResponse>, IncomingMessage, ServerResponse<IncomingMessage>, ... 4 more ..., any> | onRequestHookHandler<...>'.
            Type '(request: FastifyRequest, reply: FastifyReply, done: HookHandlerDoneFunction) => Promise<void>' is not assignable to type 'onRequestAsyncHookHandler<Server<typeof IncomingMessage, typeof ServerResponse>, IncomingMessage, ServerResponse<IncomingMessage>, ... 4 more ..., any>'.
              Target signature provides too few arguments. Expected 3 or more, but got 2.

To Reproduce

Run

npx tsc

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published