import { Children , ReactNode , ComponentType } from 'react' ; export const isEmptyChildren = ( children ) => Children . count ( children ) === 0 ; export const isFunction = < T extends ( ... args : any [ ] ) => any > ( value ) : value is T => typeof value === 'function' ; type Nullable < T > = T extends null | undefined ? T : never ; export const isPresent = < T > ( value ) : value is NonNullable < T > => value != null ; export const isBlank = < T > ( value ) : value is Nullable < T > => value == null ; const main = ( ) => { type User = { name : string ; age : undefined | number ; } ; const user = { name : 'Martin' , age : undefined } ; const { age } = user ; if ( isBlank ( age ) ) { age ; } if ( isPresent ( age ) ) { age ; } } ; export const getComponentName = ( component ) => component . displayName || ( component as any ) . name ; export const getHocComponentName = ( hocName , component ) => `${ hocName }(${ getComponentName ( component ) })` ; export type DefaultProps < P extends object , DP extends Partial < P > = Partial < P > > = Partial < DP > & Pick < P , Exclude < keyof P , keyof DP > > ; export const withDefaultProps = < P extends object , DP extends Partial < P > = Partial < P > > ( defaultProps , Cmp ) : ComponentType < DefaultProps < P , DP > > => { Cmp . defaultProps = defaultProps ; return Cmp as ComponentType < any > ; } ;