Repository: pinojs/pino-pretty (javascript)

Issue:
Unexported interface PrettyOptions causes type-check error in @types/pino
This kind of breaks pino with `TS2694: Namespace '"/node_modules/pino-pretty/index"' has no exported member 'PrettyOptions'.`

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/pino/index.d.ts#L546

[![image](https://user-images.githubusercontent.com/77545839/119976079-46a7e880-bfbf-11eb-95ec-6badd06c1a09.png)](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/pino/index.d.ts#L546)




Discussion:
On it.

Patch:
diff --git a/index.d.ts b/index.d.ts
--- a/index.d.ts
+++ b/index.d.ts
@@ -5,106 +5,107 @@
 
 type LogDescriptor = Record<string, unknown>;
 
-declare function PinoPretty(options: PinoPretty.PrettyOptions): PinoPretty.Prettifier;
+declare function PinoPretty(options: PrettyOptions_): PinoPretty.Prettifier;
+
+interface PrettyOptions_ {
+  /**
+   * Hide objects from output (but not error object).
+   * @default false
+   */
+  hideObject?: boolean;
+  /**
+   * Translate the epoch time value into a human readable date and time string. This flag also can set the format
+   * string to apply when translating the date to human readable format. For a list of available pattern letters
+   * see the {@link https://www.npmjs.com/package/dateformat|dateformat documentation}.
+   * - The default format is `yyyy-mm-dd HH:MM:ss.l o` in UTC.
+   * - Requires a `SYS:` prefix to translate time to the local system's timezone. Use the shortcut `SYS:standard`
+   *   to translate time to `yyyy-mm-dd HH:MM:ss.l o` in system timezone.
+   * @default false
+   */
+  translateTime?: boolean | string;
+  /**
+   * If set to true, it will print the name of the log level as the first field in the log line.
+   * @default false
+   */
+  levelFirst?: boolean;
+  /**
+   * Define the key that contains the level of the log.
+   * @default "level"
+   */
+  levelKey?: string;
+  /**
+   * Output the log level using the specified label.
+   * @default "levelLabel"
+   */
+  levelLabel?: string;
+  /**
+   * The key in the JSON object to use as the highlighted message.
+   * @default "msg"
+   */
+  messageKey?: string;
+  /**
+   * Print each log message on a single line (errors will still be multi-line).
+   * @default false
+   */
+  singleLine?: boolean;
+  /**
+   * The key in the JSON object to use for timestamp display.
+   * @default "time"
+   */
+  timestampKey?: string;
+  /**
+   * Format output of message, e.g. {level} - {pid} will output message: INFO - 1123
+   * @default false
+   *
+   * @example
+   * ```typescript
+   * {
+   *   messageFormat: (log, messageKey) => {
+   *     const message = log[messageKey];
+   *     if (log.requestId) return `[${log.requestId}] ${message}`;
+   *     return message;
+   *   }
+   * }
+   * ```
+   */
+  messageFormat?: false | string | PinoPretty.MessageFormatFunc;
+  /**
+   * If set to true, will add color information to the formatted output message.
+   * @default false
+   */
+  colorize?: boolean;
+  /**
+   * Appends carriage return and line feed, instead of just a line feed, to the formatted log line.
+   * @default false
+   */
+  crlf?: boolean;
+  /**
+   * Define the log keys that are associated with error like objects.
+   * @default ["err", "error"]
+   */
+  errorLikeObjectKeys?: string[];
+  /**
+   *  When formatting an error object, display this list of properties.
+   *  The list should be a comma separated list of properties.
+   * @default ""
+   */
+  errorProps?: string;
+  /**
+   * Specify a search pattern according to {@link http://jmespath.org|jmespath}
+   */
+  search?: string;
+  /**
+   * Ignore one or several keys.
+   * @example "time,hostname"
+   */
+  ignore?: string;
+}
 
 declare namespace PinoPretty {
   type Prettifier = (inputData: string | object) => string;
   type MessageFormatFunc = (log: LogDescriptor, messageKey: string, levelLabel: string) => string;
-
-  interface PrettyOptions {
-    /**
-     * Hide objects from output (but not error object).
-     * @default false
-     */
-    hideObject?: boolean;
-    /**
-     * Translate the epoch time value into a human readable date and time string. This flag also can set the format
-     * string to apply when translating the date to human readable format. For a list of available pattern letters
-     * see the {@link https://www.npmjs.com/package/dateformat|dateformat documentation}.
-     * - The default format is `yyyy-mm-dd HH:MM:ss.l o` in UTC.
-     * - Requires a `SYS:` prefix to translate time to the local system's timezone. Use the shortcut `SYS:standard`
-     *   to translate time to `yyyy-mm-dd HH:MM:ss.l o` in system timezone.
-     * @default false
-     */
-    translateTime?: boolean | string;
-    /**
-     * If set to true, it will print the name of the log level as the first field in the log line.
-     * @default false
-     */
-    levelFirst?: boolean;
-    /**
-     * Define the key that contains the level of the log.
-     * @default "level"
-     */
-    levelKey?: string;
-    /**
-     * Output the log level using the specified label.
-     * @default "levelLabel"
-     */
-    levelLabel?: string;
-    /**
-     * The key in the JSON object to use as the highlighted message.
-     * @default "msg"
-     */
-    messageKey?: string;
-    /**
-     * Print each log message on a single line (errors will still be multi-line).
-     * @default false
-     */
-    singleLine?: boolean;
-    /**
-     * The key in the JSON object to use for timestamp display.
-     * @default "time"
-     */
-    timestampKey?: string;
-    /**
-     * Format output of message, e.g. {level} - {pid} will output message: INFO - 1123
-     * @default false
-     *
-     * @example
-     * ```typescript
-     * {
-     *   messageFormat: (log, messageKey) => {
-     *     const message = log[messageKey];
-     *     if (log.requestId) return `[${log.requestId}] ${message}`;
-     *     return message;
-     *   }
-     * }
-     * ```
-     */
-    messageFormat?: false | string | MessageFormatFunc;
-    /**
-     * If set to true, will add color information to the formatted output message.
-     * @default false
-     */
-    colorize?: boolean;
-    /**
-     * Appends carriage return and line feed, instead of just a line feed, to the formatted log line.
-     * @default false
-     */
-    crlf?: boolean;
-    /**
-     * Define the log keys that are associated with error like objects.
-     * @default ["err", "error"]
-     */
-    errorLikeObjectKeys?: string[];
-    /**
-     *  When formatting an error object, display this list of properties.
-     *  The list should be a comma separated list of properties.
-     * @default ""
-     */
-    errorProps?: string;
-    /**
-     * Specify a search pattern according to {@link http://jmespath.org|jmespath}
-     */
-    search?: string;
-    /**
-     * Ignore one or several keys.
-     * @example "time,hostname"
-     */
-    ignore?: string;
-  }
+  type PrettyOptions = PrettyOptions_
 }
 
 export default PinoPretty;
-export { PinoPretty }
+export { PinoPretty, PrettyOptions_ as PrettyOptions }
diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -9,7 +9,7 @@
     "pino-pretty": "./bin.js"
   },
   "scripts": {
-    "ci": "standard && npm run test-types && tap 'test/**/*.test.js' --coverage-report=lcovonly",
+    "ci": "standard && tap 'test/**/*.test.js' --coverage-report=lcovonly && npm run test-types",
     "lint": "standard | snazzy",
     "test": "tap --100 'test/**/*.test.js'",
     "test-types": "tsc && tsd"


Test patch:
diff --git a/test/types/pino-pretty.test-d.ts b/test/types/pino-pretty.test-d.ts
--- a/test/types/pino-pretty.test-d.ts
+++ b/test/types/pino-pretty.test-d.ts
@@ -1,7 +1,7 @@
 import prettyFactory from "../../";
-import {expectType} from "tsd";
+import { expectType } from "tsd";
 
-import PinoPretty, { PinoPretty as PinoPrettyNamed } from "../../";
+import PinoPretty, { PinoPretty as PinoPrettyNamed, PrettyOptions } from "../../";
 import PinoPrettyDefault from "../../";
 import * as PinoPrettyStar from "../../";
 import PinoPrettyCjsImport = require ("../../");
@@ -26,6 +26,24 @@ const options: PinoPretty.PrettyOptions = {
   singleLine: false,
 };
 
+const options2: PrettyOptions = {
+  colorize: true,
+  crlf: false,
+  errorLikeObjectKeys: ["err", "error"],
+  errorProps: "",
+  hideObject: true,
+  levelKey: "level",
+  levelLabel: "foo",
+  messageFormat: false,
+  ignore: "",
+  levelFirst: false,
+  messageKey: "msg",
+  timestampKey: "timestamp",
+  translateTime: "UTC:h:MM:ss TT Z",
+  search: "foo == `bar`",
+  singleLine: false,
+};
+
 const pretty = prettyFactory(options);
 expectType<Prettifier>(pretty)