question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Partial override of default configuration not available when using TypeScript

See original GitHub issue

Because 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:closed
  • Created 3 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
Slessicommented, Mar 9, 2021

kinda confusing which PR to check but #309 seems ok

0reactions
mattberthercommented, Mar 10, 2021

Resolved with #307 and pushed to npm as winston-daily-rotate-file@4.5.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript interface default that will get overridden in ...
Type 'undefined' is not assignable to type 'MatchMakerType'. What can I do to set up a default that will be overridden? javascript ·...
Read more >
Documentation - TypeScript 4.3
One big one is missing renames. ... When a method is marked with override , TypeScript will always make sure that a method...
Read more >
Getting To Know The Partial Type in TypeScript
TypeScript (v2.1) provides us with a solution precisely for these cases — The Partial interface. All we need to do is to change...
Read more >
Static Application Security Testing (SAST) | GitLab
If you have a complex GitLab configuration file it may not be parsed successfully, and an error may occur. To enable and configure...
Read more >
Instructions for overriding tsconfig.json don't seem to work
I was unable to find a working solution for overriding some tsconfig ... Compiling with Angular sources in Ivy partial compilation mode.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found