Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Pino options have a generic type #304

Merged
merged 2 commits into from
Oct 28, 2023

Conversation

UndefinedBehaviour
Copy link
Contributor

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.

Copy link

@kibertoad kibertoad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tsd test for it!

@UndefinedBehaviour
Copy link
Contributor Author

Test added!

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit f19ed45 into pinojs:master Oct 28, 2023
5 checks passed
naseemkullah added a commit to naseemkullah/pino-http that referenced this pull request Dec 15, 2023
the type variable of the logger should be the custom levels type
since a recent change in pino types (pinojs#304)

fixes pinojs#313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants