diff --git a/pino.d.ts b/pino.d.ts index 2759a1de9..033ae2cd1 100644 --- a/pino.d.ts +++ b/pino.d.ts @@ -326,7 +326,7 @@ declare namespace pino { type PlaceholderTypeMapping = T extends 'd' ? number : T extends 's' - ? string | number | boolean | bigint | null | undefined | symbol + ? unknown : T extends 'j' | 'o' | 'O' ? object : never; @@ -878,4 +878,4 @@ declare function pino(options: pino.LoggerOptions, stream?: pino.DestinationStream | undefined): pino.Logger; -export = pino; \ No newline at end of file +export = pino; diff --git a/test/types/pino.test-d.ts b/test/types/pino.test-d.ts index bdb860a31..0e6df8f89 100644 --- a/test/types/pino.test-d.ts +++ b/test/types/pino.test-d.ts @@ -71,8 +71,9 @@ info({ a: 1, b: '2' }, 'hello world with %s', 'extra data'); // Extra message after placeholder expectError(info({ a: 1, b: '2' }, 'hello world with %d', 2, 'extra' )); -// metadata with messages type errors -expectError(info({ a: 1, b: '2' }, 'hello world with %s', {})); +// metadata with messages type passes, because of custom toString method +// We can't detect if the object has a custom toString method that returns a string +info({ a: 1, b: '2' }, 'hello world with %s', {}); // metadata after message expectError(info('message', { a: 1, b: '2' }));