Skip to content

fix(types): restore backward-compatible TransformableInfo for logform…fix(types): restore backward-compatible TransformableInfo for logform 2.7.0+#2601

Open
samuel-adedigba wants to merge 1 commit intowinstonjs:masterfrom
samuel-adedigba:fix/typescript-transformableinfo
Open

fix(types): restore backward-compatible TransformableInfo for logform…fix(types): restore backward-compatible TransformableInfo for logform 2.7.0+#2601
samuel-adedigba wants to merge 1 commit intowinstonjs:masterfrom
samuel-adedigba:fix/typescript-transformableinfo

Conversation

@samuel-adedigba
Copy link
Copy Markdown

Summary

Fixes #2528

This PR restores backward compatibility for TypeScript consumers after logform@2.7.0 changed TransformableInfo.message from any to unknown.

Changes

  • Re-declare TransformableInfo interface with message: any and index signature [key: string]: any
  • Re-declare format namespace functions to use the compatible TransformableInfo type
  • Add TransformFunction and FormatWrap types for custom format functions

Problem

Starting with Winston v3.17.0, valid TypeScript code like this stopped compiling:

const logger = winston.createLogger({
  format: winston.format.printf(info => {
    return `${info.level}: ${info.message}`; // Error: 'message' is 'unknown'
  })
});

Solution

Winston now re-declares a backward-compatible TransformableInfo that preserves the original any typing, shielding consumers from the upstream breaking change.

Testing

Verified TypeScript compilation with consumer-style usage patterns
All existing tests pass

… 2.7.0+

- Re-declare TransformableInfo with 'any' instead of 'unknown'
- Re-declare format namespace with compatible types
- Fixes winstonjs#2528
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

Successfully merging this pull request may close these issues.

[Bug]: Winston 3.17.0 updated to logform 2.7.0, which had an undocumented breaking change to its types

1 participant