Definitelytyped: @types/winston is missing winston.createLogger

Created on 9 Oct 2017  路  17Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/winston package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @bonnici @CodeAnimal @DABH

The function "createLogger" to create a new logger instance isn't included in the TS definitions

Most helpful comment

any news on this please?

All 17 comments

const logger = new winston.Logger() worked for me instead of
const logger = winston.createLogger()

The documentation on GitHub might be out-of-date
The type definitions and the documentation on npm seem to be accurate.

createLogger was added in winston v3.0.0-rc0, see https://github.com/winstonjs/winston/issues/1096

Is there progress on type definitions upgrade for winston 3?

Thanks for pinging on this, I'll try to work on a patch this weekend if not sooner

@DABH Awesome, looking forward to it!

So the 3.x series of winston (when createLogger appears) is actually quite a big rewrite. In particular, winston got split into a hierarchy of smaller libraries. So before I can write updated typings for winston 3.x, we have to add typings for the supporting packages. The first one is for logform - see PR #22888 . If anyone wants to check that out and test it and/or review it and/or +/-1 it, that would help move things along.

Once typings for logform are merged in, I think I'll be able to merge in typings for winston-transport, and after that's merged, updated typings for winston should be unblocked. So it will take a bit of time, but there is a clear path at least.

Meanwhile, winston 3.x is still in RC (and has known issues), the stable 2.x branch should still work for now ;)

What's the progress on this? Can I help in any way?

Typings for logform got merged in. Didn't have quite enough time over the weekend to finish the ones for winston-transport, but will get to it soon (near the top of my todo list). Then the 3.x typings should be good to go. At some point it will be extremely useful to have people test out my typings in their apps and point out any mistakes/issues.

Actually, just spoke with the winston team and we're going to try to put definitions within the winston repos rather than going through DT. This is preferred by DT and makes versioning/maintenance easier/faster for everyone. Probably best to follow ^^ that thread for further updates as we get things in shape!

any news on this please?

Looks like the latest conversation is here: https://github.com/winstonjs/winston/issues/1190

Correct, this should be closed. Latest news is there^. winston@3 will self-bundle typings without using DT. We'll open a PR to remove winston typings from DT in the not-too-distant future, once v3 is out and typings are all done.

v3 typings are merged into winston@master now -- we can probably close this issue? Final winston v3 won't be released till end of May, so at least by then we'll open a PR to remove the typings from DT. Glad this is finally done, definitions should be far more maintainable from now on!

thanks for all your hard work, edited after reading your trials and tribulations in https://github.com/winstonjs/winston/issues/1190

As of "@types/winston": "2.3.9" i still get

error TS2305: Module '".../node_modules/@types/winston/index"' has no exported member 'createLogger'.
error TS2305: Module '".../node_modules/@types/winston/index"' has no exported member 'format'.

is there something which i may be doing incorrectly/ am not aware of?

You should not be using the types/winston package anymore -- just npm install winston (which gets v3.0), that gets you the built-in Typescript definitions now (all the typings are in winston itself, not in DefinitelyTyped).

Should this be closed or moved then?

Thank you.

Was this page helpful?
0 / 5 - 0 ratings