-
Notifications
You must be signed in to change notification settings - Fork 937
Open
Description
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");
}
arminrosu, tawseefnabi, kylesnowschwartz, simonsinclair, vncsna and 6 more
Metadata
Metadata
Assignees
Labels
No labels