diff --git a/pino.d.ts b/pino.d.ts index 930c18c04..1227dcfcd 100644 --- a/pino.d.ts +++ b/pino.d.ts @@ -123,7 +123,7 @@ export interface LoggerExtras extends EventEmitter { /** * Flushes the content of the buffer when using pino.destination({ sync: false }). */ - flush(): () => void; + flush(): void; } diff --git a/test/syncfalse.test.js b/test/syncfalse.test.js index cf169882e..b118ed9da 100644 --- a/test/syncfalse.test.js +++ b/test/syncfalse.test.js @@ -112,7 +112,7 @@ test('sync false with child', async ({ equal, teardown }) => { }) }) -test('flush does nothing with sync true (default)', async () => { +test('flush does nothing with sync true (default)', async ({ equal }) => { const instance = require('..')() - instance.flush() + equal(instance.flush(), undefined) }) diff --git a/test/transport/syncfalse.test.js b/test/transport/syncfalse.test.js index 42ada5a6f..81111b532 100644 --- a/test/transport/syncfalse.test.js +++ b/test/transport/syncfalse.test.js @@ -10,7 +10,7 @@ const { watchFileCreated, file } = require('../helper') const { pid } = process const hostname = os.hostname() -test('thread-stream async flush', async ({ same }) => { +test('thread-stream async flush', async ({ equal, same }) => { const destination = file() const transport = pino.transport({ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'), @@ -18,7 +18,9 @@ test('thread-stream async flush', async ({ same }) => { }) const instance = pino(transport) instance.info('hello') - instance.flush() + + equal(instance.flush(), undefined) + await watchFileCreated(destination) const result = JSON.parse(await readFile(destination)) delete result.time diff --git a/test/types/pino.test-d.ts b/test/types/pino.test-d.ts index 6ae04f542..9e4786de6 100644 --- a/test/types/pino.test-d.ts +++ b/test/types/pino.test-d.ts @@ -111,6 +111,7 @@ pino({ base: null }); // @ts-expect-error if ("pino" in log) console.log(`pino version: ${log.pino}`); +expectType(log.flush()); log.child({ a: "property" }).info("hello child!"); log.level = "error"; log.info("nope");