fastify / fastify-request-context

Request-scoped storage support, based on Asynchronous Local Storage (with fallback to cls-hooked)
MIT License
153 stars 13 forks source link

childLoggerFactory option appears to be missing from typescript types #194

Closed FabianFrank closed 1 week ago

FabianFrank commented 1 week ago

Prerequisites

Fastify version

4.26.2

Plugin version

No response

Node.js version

v22.0.0

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

Sonoma 14.6.1

Description

The example given in https://fastify.dev/docs/latest/Reference/Server/#setchildloggerfactory makes it seem like the following typescript should work:

const test = Fastify({
  childLoggerFactory(logger, bindings, opts, rawReq) {
    // Calculate additional bindings from the request if needed
    bindings.traceContext = rawReq.headers["x-cloud-trace-context"]
    return logger.child(bindings, opts)
  },
})

However, it produces the following type error:

No overload matches this call.
  The last overload gave the following error.
    Object literal may only specify known properties, and 'childLoggerFactory' does not exist in type 'FastifyHttpOptions<Server<typeof IncomingMessage, typeof ServerResponse>, FastifyBaseLogger>'.ts(2769)

Link to code that reproduces the bug

No response

Expected Behavior

The types should define the childLoggerFactory option and there should be no type error

FabianFrank commented 1 week ago

wrong repo sorry!