#Extending an generic interface

1 messages · Page 1 of 1 (latest)

glad nacelle
#

I'm trying to build an generic interface that will extend type T that also had a default of {}.

I'm getting an error saying that children, and className are not defined in CardCountentProps. However they should be exists as they are part of HTMLAttributes<HTMLDivElement>


export interface TailwindAttributesTypes<T = {}> extends T {
  justify?: JustifyTypes,
  items?: ItemsType;
}

export interface CardContentProps extends TailwindAttributesTypes<HTMLAttributes<HTMLDivElement>> {}

const CardContent = (props: CardContentProps) => {
  const { children, className, justify = 'start', items = 'start', ...rest } = props;
  return (
    <h2
      className={clsx(
        'flex flex-col flex-1',
        className
      )}
      {...rest}>
      {children}
    </h2>
  );
};

export default CardContent;
frank marten
#

AFAIK, you can't do that. You could achieve something similar using a type alias though