File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -630,7 +630,7 @@ declare namespace pino {
630630 /**
631631 * Optional child creation callback.
632632 */
633- onChild ?: OnChildCallback ;
633+ onChild ?: OnChildCallback < CustomLevels > ;
634634
635635 /**
636636 * logs newline delimited JSON with `\r\n` instead of `\n`. Default: `false`.
@@ -799,7 +799,7 @@ declare function pino<CustomLevels extends string = never>(optionsOrStream?: Log
799799 * relative protocol is enabled. Default: process.stdout
800800 * @returns a new logger instance.
801801 */
802- declare function pino < CustomLevels extends string > ( options : LoggerOptions < CustomLevels > , stream : DestinationStream ) : Logger < CustomLevels > ;
802+ declare function pino < CustomLevels extends string = never > ( options : LoggerOptions < CustomLevels > , stream : DestinationStream ) : Logger < CustomLevels > ;
803803
804804
805805// Pass through all the top-level exports, allows `import {version} from "pino"`
Original file line number Diff line number Diff line change @@ -404,3 +404,23 @@ expectType<Logger<'log'>>(pino({
404404 } ,
405405 } ,
406406} ) )
407+
408+ const parentLogger1 = pino ( {
409+ customLevels : { myLevel : 90 } ,
410+ onChild : ( child ) => { const a = child . myLevel ; }
411+ } , process . stdout )
412+ parentLogger1 . onChild = ( child ) => { child . myLevel ( '' ) ; }
413+
414+ const childLogger1 = parentLogger1 . child ( { } ) ;
415+ childLogger1 . myLevel ( '' ) ;
416+ expectError ( childLogger1 . doesntExist ( '' ) ) ;
417+
418+ const parentLogger2 = pino ( { } , process . stdin ) ;
419+ expectError ( parentLogger2 . onChild = ( child ) => { const b = child . doesntExist ; } ) ;
420+
421+ const childLogger2 = parentLogger2 . child ( { } ) ;
422+ expectError ( childLogger2 . doesntExist ) ;
423+
424+ expectError ( pino ( {
425+ onChild : ( child ) => { const a = child . doesntExist ; }
426+ } , process . stdout ) ) ;
You can’t perform that action at this time.
0 commit comments