diff --git a/index.d.ts b/index.d.ts index c606d682..0b35579e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,11 +1,17 @@ -// Type definitions for pino-pretty 4.7 +// Type definitions for pino-pretty 7.0 // Project: https://github.com/pinojs/pino-pretty#readme // Definitions by: Adam Vigneaux +// tearwyx // Minimum TypeScript Version: 3.0 +/// + +import { Transform } from 'stream'; +import { OnUnknown } from 'pino-abstract-transport'; + type LogDescriptor = Record; -declare function PinoPretty(options: PrettyOptions_): PinoPretty.Prettifier; +declare function PinoPretty(options: PrettyOptions_): PinoPretty.PrettyStream; interface PrettyOptions_ { /** @@ -121,8 +127,9 @@ interface PrettyOptions_ { declare namespace PinoPretty { type Prettifier = (inputData: string | object) => string; type MessageFormatFunc = (log: LogDescriptor, messageKey: string, levelLabel: string) => string; - type PrettyOptions = PrettyOptions_ + type PrettyOptions = PrettyOptions_; + type PrettyStream = Transform & OnUnknown; } export default PinoPretty; -export { PinoPretty, PrettyOptions_ as PrettyOptions } +export { PinoPretty, PrettyOptions_ as PrettyOptions }; diff --git a/test/types/pino-pretty.test-d.ts b/test/types/pino-pretty.test-d.ts index a4749f86..72bdd8c8 100644 --- a/test/types/pino-pretty.test-d.ts +++ b/test/types/pino-pretty.test-d.ts @@ -1,11 +1,11 @@ -import prettyFactory from "../../"; import { expectType } from "tsd"; +import pretty from "../../"; import PinoPretty, { PinoPretty as PinoPrettyNamed, PrettyOptions } from "../../"; import PinoPrettyDefault from "../../"; import * as PinoPrettyStar from "../../"; -import PinoPrettyCjsImport = require ("../../"); -import Prettifier = PinoPretty.Prettifier; +import PinoPrettyCjsImport = require("../../"); +import PrettyStream = PinoPretty.PrettyStream; const PinoPrettyCjs = require("../../"); const options: PinoPretty.PrettyOptions = { @@ -52,16 +52,11 @@ const options2: PrettyOptions = { } }; -const pretty = prettyFactory(options); -expectType(pretty); - -expectType(PinoPrettyNamed(options)); -expectType(PinoPrettyDefault(options)); -expectType(PinoPrettyStar.PinoPretty(options)); -expectType(PinoPrettyStar.default(options)); -expectType(PinoPrettyCjsImport.PinoPretty(options)); -expectType(PinoPrettyCjsImport.default(options)); +expectType(pretty(options)); +expectType(PinoPrettyNamed(options)); +expectType(PinoPrettyDefault(options)); +expectType(PinoPrettyStar.PinoPretty(options)); +expectType(PinoPrettyStar.default(options)); +expectType(PinoPrettyCjsImport.PinoPretty(options)); +expectType(PinoPrettyCjsImport.default(options)); expectType(PinoPrettyCjs(options)); - -expectType(pretty({ foo: "bar" })); -expectType(pretty('dummy'));