Partial override of default configuration not available when using TypeScript
See original GitHub issueBecause the typing for DailyRotateFileTransportOptions
includes RequireOnlyOne<GeneralDailyRotateFileTransportOptions, 'filename' | 'stream'>
, TypeScript will complain if neither a filename
nor a stream
is specified in the options object.
In the README, filename
is listed as having a default value of 'winston.log.%DATE%
(which I’m pretty sure is a typo [no closing single-quote] anyway), and stream
is listed as default null
. From reading the README, I expect that creating a transport like this:
winston.createLogger({
transports: [
new DailyRotateFile({
dirname: 'logs',
}),
],
});
will work, allowing me to use the default filename
option with my own custom dirname
option. However, this does not work. TypeScript says that the type { dirname: string; }
is not assignable to the parameter. Fixing it like this:
new DailyRotateFile({
filename: 'winston.log.%DATE%',
dirname: 'logs',
}),
works, of course, but in the absence of a custom filename
, the default should be allowed, even with other custom options like dirname
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (12 by maintainers)
Top GitHub Comments
kinda confusing which PR to check but #309 seems ok
Resolved with #307 and pushed to npm as
winston-daily-rotate-file@4.5.1
.