diff --git a/CHANGELOG.md b/CHANGELOG.md index 422610536..d3394b549 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## UNRELEASED + +**TypeScript** +- [#2528] Fix backward-compatible `TransformableInfo` type for logform 2.7.0+ breaking change + ## [v3.9.0](https://github.com/winstonjs/winston/compare/v3.8.2...v3.9.0) ### Functionality changes * Handle undefined errors in getAllInfo in exception-handler in https://github.com/winstonjs/winston/pull/2208; thanks to new contributor @eivindrs diff --git a/index.d.ts b/index.d.ts index b710af7a4..1dc66a37c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -13,7 +13,38 @@ import * as Transports from './lib/winston/transports/index'; declare namespace winston { // Hoisted namespaces from other modules - export import format = logform.format; + // Backward-compatible TransformableInfo for logform 2.7.0+ + // https://github.com/winstonjs/winston/issues/2528 + interface TransformableInfo { + level: string; + message: any; + [key: string]: any; + } + type TransformFunction = (info: TransformableInfo, opts?: any) => TransformableInfo | boolean; + type FormatWrap = (opts?: any) => logform.Format; + + function format(transform: TransformFunction): FormatWrap; + namespace format { + function align(): logform.Format; + function cli(opts?: logform.CliOptions): logform.Format; + function colorize(opts?: logform.ColorizeOptions): logform.Colorizer; + function combine(...formats: logform.Format[]): logform.Format; + function errors(opts?: object): logform.Format; + function json(opts?: logform.JsonOptions): logform.Format; + function label(opts?: logform.LabelOptions): logform.Format; + function logstash(): logform.Format; + function metadata(opts?: logform.MetadataOptions): logform.Format; + function ms(): logform.Format; + function padLevels(opts?: logform.PadLevelsOptions): logform.Format; + function prettyPrint(opts?: logform.PrettyPrintOptions): logform.Format; + function printf(templateFunction: (info: TransformableInfo) => string): logform.Format; + function simple(): logform.Format; + function splat(): logform.Format; + function timestamp(opts?: logform.TimestampOptions): logform.Format; + function uncolorize(opts?: logform.UncolorizeOptions): logform.Format; + } + + // Re-export logform types for consumers who need them export import Logform = logform; export import config = Config; export import transports = Transports;