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

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

Closed
Nol-go opened this issue Mar 5, 2024 · 3 comments · Fixed by #2434

Comments

@Nol-go
Copy link

Nol-go commented Mar 5, 2024

🔎 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)
@cass-codes
Copy link

[first time commenting]

Just a note that I am also having this issue.

Example

const logger = createLogger({
   transports,
   exitOnError: false,
   levels: [ "error", "warning", "info", "debug" ],
});

logger.warning("hello world");
// ^^^  error TS2339: Property 'warning' does not exist on type 'Logger'

@Kaladin13
Copy link

Same here

error TS2339: Property 'crit' does not exist on type 'Logger'

@DABH
Copy link
Contributor

DABH commented Mar 24, 2024

Resolved in 3.12.1

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

Successfully merging a pull request may close this issue.

4 participants