Skip to content

stdTimeFunctions property not found in TypeScript typings #2260

@dc7290

Description

@dc7290

Hi,

When using pino with TypeScript, I encountered the following error:

const { pino } = require('pino');
pino.stdTimeFunctions;
//              ^ error TS2339: Property 'stdTimeFunctions' does not exist on type '...'.

It seems that stdTimeFunctions is available at runtime, but the TypeScript definitions do not include it.

Environment:

pino: v9.9.0

Expected behavior:
TypeScript typings should expose pino.stdTimeFunctions without error.

Example of modification:

How about modifying it as follows?

pino.d.ts

 namespace pino {
-    //// Nested version of default export for TypeScript/Babel compatibility
-
-    /**
-     * @param [optionsOrStream]: an options object or a writable stream where the logs will be written. It can also receive some log-line metadata, if the
-     * relative protocol is enabled. Default: process.stdout
-     * @returns a new logger instance.
-     */
-    function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(optionsOrStream?: LoggerOptions<CustomLevels, UseOnlyCustomLevels> | DestinationStream): Logger<CustomLevels, UseOnlyCustomLevels>;
-
-    /**
-     * @param [options]: an options object
-     * @param [stream]: a writable stream where the logs will be written. It can also receive some log-line metadata, if the
-     * relative protocol is enabled. Default: process.stdout
-     * @returns a new logger instance.
-     */
-    function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(options: LoggerOptions<CustomLevels, UseOnlyCustomLevels>, stream?: DestinationStream | undefined): Logger<CustomLevels, UseOnlyCustomLevels>;
+    //// Nested version of default export for TypeScript/Babel compatibility
+    /**
+     * Mirrors the default export including its static properties, so that
+     * `const { pino } = require('pino')` preserves the callable type *and*
+     * static members like `stdTimeFunctions`.
+     */
+    const pino: typeof import("pino");
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions