import unsafeErrorLog from './unsafe-error-log' ; type PIndex = { [ index ] : unknown ; } ; export type FeatureOptions < P extends object > = { featureProps : Partial < P > ; unsupportedProps : Partial < P > ; } ; export default < P extends object > ( componentName , props , options ) => { const { featureProps , unsupportedProps } = options ; const featurePropNames = Object . keys ( featureProps ) ; if ( featurePropNames . every ( propName => ( props as PIndex ) [ propName ] !== ( featureProps as PIndex ) [ propName ] ) ) { return props ; } const unsupportedPropNames = Object . keys ( unsupportedProps ) ; if ( unsupportedPropNames . some ( propName => ( props as PIndex ) [ propName ] ) ) { unsafeErrorLog ( `${ componentName } doesn't support: ${ unsupportedPropNames . join ( ', ' ) } props when used with ${ JSON . stringify ( featureProps ) }` ) ; return { ... props , ... unsupportedProps } ; } return props ; } ;