Skip to content

[Bug]: commit c3c391122c44e3f0a46758997bfbb83aaea204ab breaks types for logger when using syslog #2424

@hugo-daclon

Description

@hugo-daclon

🔎 Search Terms

types, alert

The problem

@wbt removed types in the following commit: c3c3911

I now get typescript and eslint errors when using the logger with syslog levels

What version of Winston presents the issue?

v3.12.0

What version of Node are you using?

v18.19.0

If this worked in a previous version of Winston, which was it?

3.11.0

Minimum Working Example

const logger = createLogger({levels: config.syslog.levels, transports: [new transports.Console()]})

logger.alert('my alert message')
//        ^Unsafe call of an `any` typed value.eslint[@typescript-eslint/no-unsafe-call](https://typescript-eslint.io/rules/no-unsafe-call)
//        ^Property 'alert' does not exist on type 'Logger'.ts(2339)

Additional information

You can either:

  • put them back or mark them (along with every LeveledLogMethod) as optional.
  • try and work some typescript magic to detect what methods to include depending on the config value of levels. maybe something like making the logger type generic with a <levels extends Config.AbstractConfigSetLevels> and a [level: keyof levels]: LeveledLogMethod (I didn't try this, but intuitively it should work)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions