import ReactReconciler from 'react-reconciler' ; type Primitive = boolean | number | undefined | number | string | symbol ; function isPrimitive ( val ) { if ( typeof val === 'object' ) { return val === null ; } return typeof val !== 'function' ; } function Log ( target ) { function decorate < F extends ( ... args : any [ ] ) => any > ( label , fn ) { const decoratedFn = ( ... args ) => { console . group ( label , args ) ; const val = fn ( ... args ) ; const primitive = isPrimitive ( val ) ; if ( primitive ) { console . groupCollapsed ( `return ${ val }` ) ; } else { console . groupCollapsed ( 'return' ) ; } console . info ( val ) ; console . groupEnd ( ) ; console . groupEnd ( ) ; return val ; } ; return decoratedFn as unknown as F ; } Object . keys ( target ) . forEach ( key => { const fn = target [ key ] ; if ( typeof fn === 'function' ) { target [ key ] = decorate ( key , fn ) ; } } ) ; } export function Reconciler < Type , Props , Container , Instance , TextInstance , HydratableInstance , PublicInstance , HostContext , UpdatePayload , ChildSet , TimeoutHandle , NoTimeout > ( config ) { if ( process . env . DEBUG_RECONCILER === 'true' ) { Log ( config ) ; } ( config as any ) . schedulePassiveEffects = config . scheduleDeferredCallback ; ( config as any ) . cancelPassiveEffects = config . cancelDeferredCallback ; return ReactReconciler ( config ) ; }