Skip to content

[Bug]: Typescript - info() is not a function#2348

Description

@1tmb

馃攷 Search Terms

typescript,info,logger

The problem

README.md is clear that the following syntax is legal:

logger.info('Hello world')

However I cannot get this to work with Typescript.

Versions:

Winston version: 3.10.0
Node version: v20.5.1

Example:

Using "esModuleInterop": true in tsconfig.json to allow the use of Winston using import syntax:

import { Logger, transports, format } from 'winston'
const logger = new Logger({
  level: 'debug',
  transports: [new transports.Console()],
  format: format.combine(format.splat(), format.colorize({ all: true }), format.simple())
})

logger.info('Hello world')

export default logger

Expected:

Console output of: Hello world

Actual:

logger_1.default.info is not a function

What version of Winston presents the issue?

3.10.0

What version of Node are you using?

20.5.1

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

No response

Minimum Working Example

Using "esModuleInterop": true in tsconfig.json to allow the use of Winston using import syntax:

import { Logger, transports, format } from 'winston'
const logger = new Logger({
  level: 'debug',
  transports: [new transports.Console()],
  format: format.combine(format.splat(), format.colorize({ all: true }), format.simple())
})

logger.info('Hello world')

export default logger

Additional information

No response

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