winston: createLogger breaking changes under patch release
Please tell us about your environment:
winstonversion?- [+]
winston@3
- [+]
node -voutputs:- Operating System? macOS
- Language? Typescript 3.5.3
What is the problem?
createLogger exported by winston, will now return Logger<winston.AbstractConfigSetLevels> which is a breaking change as before 3.3.0/3.3.1 release createLogger would return Logger.
What do you expect to happen instead?
Breaking change is introduced in a major version
Other information
n/a
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 15 (9 by maintainers)
Commits related to this issue
- Fix issue #1817 (#1819) * fix: replace type with generic * fix: typo — committed to winstonjs/winston by Pigotz 4 years ago
@DABH Sorry to commit code with some mistakes… 😭 @Pigotz Thanks for fixing it! 👍
@rossanmol Hmm, sorry but I can’t figure out what problem occurred. Do you face some concrete problems because of this change, or you wanna just mention this is breaking change? If you have some problem, can you explain it in detail?
In my environment,
T extends Config.AbstractConfigSetLevels = DefaultLevelsis enough andT extends Config.AbstractConfigSetLevels = DefaultLevels | Config.AbstractConfigSetLevelsdoesn’t make any difference. (because if you omit the generics, alwaysDefaultLevelsis set.)Anyway, sorry to commit the breaking change in patch release. 🙇
@sigorilla , I’m waiting for the fixes/changes proposed by @AuHau @Mizumaki @rossanmol . Will give those folks a few hours – I will check back in a few hours and hopefully we can get a proper fix merged and released then. Thanks all.
Also, I believe that the methods that return another
Loggerinstance should use the “parent’s” generic.E.g. currently
childis typed aschild(options: Object): Logger. I would argue it should bechild(options: Object): Logger<T>.Here is a sample code, with the new problem (with the changes of #1817):
As you can see, DefaultLevels is too strict compared to what we had before.
Ahhhh, maybe I understand.
This is your problem. right ? If you type
Loggerdirectly, there is an error occurred.Wait for me to fix it. really sorry