Skip to content

[Bug]: logform v2.7.0 breaks usages of its types without being a major version #336

@ItsHarper

Description

@ItsHarper

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions