-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
The problem
Code that uses logform types (in my case a custom Winston formatter) and previously passed type-checking in logform 2.6.1 can in some cases no longer pass type-checking with logform 2.7.0, because usages of any were replaced with unknown. #325 was a good change, but it should have been made in a major release of logform, whichwinston-transport and winston should not have updated to without bumping their major versions as well.
#325 should be reverted and postponed until logform 4.0.
What version of Logform presents the issue?
2.7.0
What version of Node are you using?
v20.18.0
If this is a TypeScript issue, what version of TypeScript are you using?
v5.5.4
If this worked in a previous version of Logform, which was it?
2.6.1
Minimum Working Example
import { format } from "winston";
// https://github.com/winstonjs/winston/issues/1660#issuecomment-512226578
const fixErrorsFormat = format((info) => {
// Only modify the info it there was an error
if (info.stack === undefined) {
return info;
}
const { message } = info;
// Get the original error message
const errorMessage =
info[Symbol.for("splat")] &&
info[Symbol.for("splat")][0] &&
info[Symbol.for("splat")][0].message;
// Check that the original error message was concatenated to the message
if (
errorMessage === undefined ||
message.length <= errorMessage.length ||
!message.endsWith(errorMessage)
) {
return info;
}
// Slice off the original error message from the log message
info.message = message.slice(0, errorMessage.length * -1).trim();
return info;
});Additional information
No response
🔎 Search Terms
typescript, unknown, any, breaking change
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels