-
Notifications
You must be signed in to change notification settings - Fork 764
Description
Hi. My project doesn't directly use log4js but we do want to make sure that a logger argument we take is compatible with log4js objects, so our test suite sets up log4js and sends a message through it (via our ApolloServer object) and tests that it works.
Renovate picked up the 6.4.0 release but this test file doesn't compile with the changes to your TypeScript types in v6.4.0.
I honestly don't understand log4js well enough to be sure, but it looks like the issue is specific to the types, not an actual change to your JS code.
Specifically, we call:
log4js.configure({
appenders: {
custom: {
type: {
configure: () => (loggingEvent: log4js.LoggingEvent) =>
sink(loggingEvent),
},
},
},
categories: {
default: {
appenders: ['custom'],
level: LOWEST_LOG_LEVEL,
},
},
});
According to your types file, the configure function is a (config: Config, layouts: LayoutsParam) => AppenderGenerator, and AppenderGenerator is (layout: LayoutFunction, timezoneOffset?: string) => AppenderFunction, and AppenderFunction is (loggingEvent: LoggingEvent) => void.
This is one more layer of "function" than the code above that previously worked for us: the outer () => is the (config, layouts) => type, and the inner (loggingEvent) => function is an AppenderFunction, but we were not writing an AppenderGenerator in the middle.
OK, I said. This seemed like an odd backwards-incompatibility to put out in a minor release, but sure. I added another () => after the first () => above... and my test failed.
I reverted that change and instead added an as any somewhere... and my test passed.
So... I don't really know much about log4js. But it seems like what happened here is that v6.4.0 did not actually change your API as implemented in JS, but that the TypeScript changes introduced an intermediate function that isn't actually part of code.
Specifically it seems like maybe AppenderGenerator isn't a real thing and that AppenderModule should be declared as
export interface AppenderModule {
configure: (config: Config, layouts: LayoutsParam) => AppenderFunction;
}
Am I missing something?