From c58bbd19be1e3f28f61fdd4ba6322b761b506c50 Mon Sep 17 00:00:00 2001 From: baptistegarcin Date: Mon, 17 Nov 2025 18:34:30 +0100 Subject: [PATCH] feat(types): add generic type support to TransformableInfo Convert TransformableInfo from interface to generic type with TCustom parameter, allowing custom properties to be properly typed. Update printf function to support the generic parameter for better type inference when using custom fields. --- index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 0824a8d..bf2b5b0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -5,14 +5,14 @@ // TypeScript Version: 2.2 import {LEVEL, MESSAGE, SPLAT} from 'triple-beam' -export interface TransformableInfo { +export type TransformableInfo = TCustom & { level: string; message: unknown; [LEVEL]?: string; [MESSAGE]?: unknown; [SPLAT]?: unknown; [key: string | symbol]: unknown; -} +}; export type TransformFunction = (info: TransformableInfo, opts?: unknown) => TransformableInfo | boolean; export type Colors = { [key: string]: string | string[] }; // tslint:disable-line interface-over-type-literal @@ -50,7 +50,7 @@ export namespace format { function ms(): Format; function padLevels(opts?: PadLevelsOptions): Format; function prettyPrint(opts?: PrettyPrintOptions): Format; - function printf(templateFunction: (info: TransformableInfo) => string): Format; + function printf(templateFunction: (info: TransformableInfo) => string): Format; function simple(): Format; function splat(): Format; function timestamp(opts?: TimestampOptions): Format; @@ -107,7 +107,7 @@ export interface JsonOptions { /** * If `true`, guarantee a deterministic key order instead of relying on the insertion order. * Set to `false` to keep original insertion order. - * Or provide an array comparator function that determines the order of the elements. + * Or provide an array comparator function that determines the order of the elements. * @default true */ deterministic?: boolean | ((a: string, b: string) => number),