Skip to content

Commit ddafa94

Browse files
authoredNov 22, 2021
fix: update return type of function exported by default (#273) (#274)
1 parent c070efb commit ddafa94

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed
 

‎index.d.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
// Type definitions for pino-pretty 4.7
1+
// Type definitions for pino-pretty 7.0
22
// Project: https://github.com/pinojs/pino-pretty#readme
33
// Definitions by: Adam Vigneaux <https://github.com/AdamVig>
4+
// tearwyx <https://github.com/tearwyx>
45
// Minimum TypeScript Version: 3.0
56

7+
/// <reference types="node" />
8+
9+
import { Transform } from 'stream';
10+
import { OnUnknown } from 'pino-abstract-transport';
11+
612
type LogDescriptor = Record<string, unknown>;
713

8-
declare function PinoPretty(options: PrettyOptions_): PinoPretty.Prettifier;
14+
declare function PinoPretty(options: PrettyOptions_): PinoPretty.PrettyStream;
915

1016
interface PrettyOptions_ {
1117
/**
@@ -121,8 +127,9 @@ interface PrettyOptions_ {
121127
declare namespace PinoPretty {
122128
type Prettifier = (inputData: string | object) => string;
123129
type MessageFormatFunc = (log: LogDescriptor, messageKey: string, levelLabel: string) => string;
124-
type PrettyOptions = PrettyOptions_
130+
type PrettyOptions = PrettyOptions_;
131+
type PrettyStream = Transform & OnUnknown;
125132
}
126133

127134
export default PinoPretty;
128-
export { PinoPretty, PrettyOptions_ as PrettyOptions }
135+
export { PinoPretty, PrettyOptions_ as PrettyOptions };

‎test/types/pino-pretty.test-d.ts

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import prettyFactory from "../../";
21
import { expectType } from "tsd";
32

3+
import pretty from "../../";
44
import PinoPretty, { PinoPretty as PinoPrettyNamed, PrettyOptions } from "../../";
55
import PinoPrettyDefault from "../../";
66
import * as PinoPrettyStar from "../../";
7-
import PinoPrettyCjsImport = require ("../../");
8-
import Prettifier = PinoPretty.Prettifier;
7+
import PinoPrettyCjsImport = require("../../");
8+
import PrettyStream = PinoPretty.PrettyStream;
99
const PinoPrettyCjs = require("../../");
1010

1111
const options: PinoPretty.PrettyOptions = {
@@ -52,16 +52,11 @@ const options2: PrettyOptions = {
5252
}
5353
};
5454

55-
const pretty = prettyFactory(options);
56-
expectType<Prettifier>(pretty);
57-
58-
expectType<Prettifier>(PinoPrettyNamed(options));
59-
expectType<Prettifier>(PinoPrettyDefault(options));
60-
expectType<Prettifier>(PinoPrettyStar.PinoPretty(options));
61-
expectType<Prettifier>(PinoPrettyStar.default(options));
62-
expectType<Prettifier>(PinoPrettyCjsImport.PinoPretty(options));
63-
expectType<Prettifier>(PinoPrettyCjsImport.default(options));
55+
expectType<PrettyStream>(pretty(options));
56+
expectType<PrettyStream>(PinoPrettyNamed(options));
57+
expectType<PrettyStream>(PinoPrettyDefault(options));
58+
expectType<PrettyStream>(PinoPrettyStar.PinoPretty(options));
59+
expectType<PrettyStream>(PinoPrettyStar.default(options));
60+
expectType<PrettyStream>(PinoPrettyCjsImport.PinoPretty(options));
61+
expectType<PrettyStream>(PinoPrettyCjsImport.default(options));
6462
expectType<any>(PinoPrettyCjs(options));
65-
66-
expectType<string>(pretty({ foo: "bar" }));
67-
expectType<string>(pretty('dummy'));

0 commit comments

Comments
 (0)
Please sign in to comment.