Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NoahAndrews opened this issue Nov 13, 2024 · 6 comments

Comments

@NoahAndrews
Copy link

NoahAndrews commented Nov 13, 2024

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

@GianniCodato-PixartPrinting

Same issue also on our codebase (but function printf instead of format)

@alumni
Copy link

alumni commented Nov 19, 2024

yes, it's 55f3d8c changing any to unknown in TransformableInfo. Would be nice if TransformableInfo would be a generic, so we could pass it our own keys.

@Cooldude2606
Copy link

Issue also with changing any to unknown for opts param to TransformFunction which was introduced in 55f3d8c
Breaking change caused a build pipeline fail and required a hot patch.

@alexweej
Copy link

Same problem at my org. Is there actually anyone objecting to 'fixing' this in a new semver minor? Curious if there's consensus. Thanks all!

@apanjwani0
Copy link

Please fix this.
55f3d8c#commitcomment-148941012

@dscalzi
Copy link

dscalzi commented Nov 29, 2024

@DABH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants