unjs / consola

🐨 Elegant Console Logger for Node.js and Browser
Other
6.12k stars 175 forks source link

BasicReporterOptions/FormatOptions incorrectly typed to nodejs util.InspectOptions #123

Closed JustinGrote closed 1 year ago

JustinGrote commented 3 years ago

Currently I cannot derive from BasicReporter due to this. https://github.com/unjs/consola/blob/abb016f568e8942a3c3222258757bfff14304f7c/types/consola.d.ts#L130

Workaround patch for patch-package:

diff --git a/node_modules/consola/types/consola.d.ts b/node_modules/consola/types/consola.d.ts
index f98f7aa..bdc31e6 100644
--- a/node_modules/consola/types/consola.d.ts
+++ b/node_modules/consola/types/consola.d.ts
@@ -1,4 +1,3 @@
-import { InspectOptions } from 'util';

 export enum LogLevel {
   Fatal= 0,
@@ -125,9 +124,14 @@ export declare class Consola {
   mock(mockFn: ConsolaMockFn): any
 }

+interface BasicReporterFormatOptions {
+    date?: boolean,
+    colors?: boolean,
+    compact?: boolean
+}
 export interface BasicReporterOptions {
   dateFormat?: string;
-  formatOptions?: InspectOptions;
+  formatOptions?: BasicReporterFormatOptions;
 }

 export declare class BasicReporter implements ConsolaReporter {
pi0 commented 1 year ago

Thanks for reporting. Consola v3 should allow this via top level formatOptions