Skip to content

Commit

Permalink
Add missing TypeScript declarations (#300) (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
CoeJoder authored Feb 26, 2022
1 parent 3ff7b1c commit e9efbd7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ The options accepted have keys corresponding to the options described in [CLI Ar
// You can also configure some SonicBoom options directly
sync: false, // by default we write asynchronously
append: true, // the file is opened with the 'a' flag
mdkdir: true, // create the target destination
mkdir: true, // create the target destination


customPrettifiers: {}
Expand All @@ -262,6 +262,9 @@ The options accepted have keys corresponding to the options described in [CLI Ar
The `colorize` default follows
[`colorette.isColorSupported`](https://github.com/jorgebucaran/colorette#iscolorsupported).

The defaults for `sync`, `append`, `mkdir` inherit from
[`SonicBoom(opts)`](https://github.com/pinojs/sonic-boom#API).

`customPrettifiers` option provides the ability to add a custom prettify function
for specific log properties. `customPrettifiers` is an object, where keys are
log properties that will be prettified and value is the prettify function itself.
Expand Down
16 changes: 16 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { Transform } from 'stream';
import { OnUnknown } from 'pino-abstract-transport';
import { DestinationStream } from 'pino';

type LogDescriptor = Record<string, unknown>;

Expand Down Expand Up @@ -106,6 +107,21 @@ interface PrettyOptions_ {
* @default false
*/
sync?: boolean;
/**
* The file, file descriptor, or stream to write to. Defaults to 1 (stdout).
* @default 1
*/
destination?: string | number | DestinationStream | NodeJS.WritableStream;
/**
* Opens the file with the 'a' flag.
* @default true
*/
append?: boolean;
/**
* Ensure directory for destination file exists.
* @default false
*/
mkdir?: boolean;
/**
* Provides the ability to add a custom prettify function for specific log properties.
* `customPrettifiers` is an object, where keys are log properties that will be prettified
Expand Down
4 changes: 4 additions & 0 deletions test/types/pino-pretty.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const options: PinoPretty.PrettyOptions = {
}
},
sync: false,
append: true,
mkdir: true,
};

const options2: PrettyOptions = {
Expand All @@ -52,6 +54,8 @@ const options2: PrettyOptions = {
}
},
sync: false,
append: true,
mkdir: true,
};

expectType<PrettyStream>(pretty(options));
Expand Down

0 comments on commit e9efbd7

Please sign in to comment.