pinojs / pino-http

🌲 high-speed HTTP logger for Node.js
MIT License
539 stars 117 forks source link

fix: Pino options have a generic type #304

Closed UndefinedBehaviour closed 1 year ago

UndefinedBehaviour commented 1 year ago

Issue

import { pinoHttp } from 'pino-http';

const httpLogger = pinoHttp({
    customLevels: {
        log: 20,
    },
});

const logger = httpLogger.logger;

function f(level: 'warn' | 'info' | 'log', message: string): void {
  logger[level](message);
}

This code is correct but currently throws a ts(7053) : Element implicitly has an 'any' type because TS can't see the custom level added in the configuration.

UndefinedBehaviour commented 1 year ago

Test added!