vaadin / react-components

15 stars 4 forks source link

Components export props type that is not compatible with parameters #139

Closed TatuLund closed 11 months ago

TatuLund commented 1 year ago

Say, if I want to extend a component by wrapping it, I would like to avoid define props type again. Vaadin React components indeed export props type, like Button exports ButtonProps. However object of this type is not accepted as a parameter, hence the exported type does not have any purpose.

I would expect this to work

export function LinkButton(props: ButtonProps) {
  return (
    <Button {...props} theme="tertiary link" />
  );
}

But it does not

image

The workaround is to exclude the offending prop.

export type LinkButtonProps = Omit<ButtonProps, 'dangerouslySetInnerHTML'>;

web-padawan commented 11 months ago

This is no longer a problem with @hilla/react-components 2.3.0, possibly due to the Lit version bump:

Before

Screenshot 2023-12-13 at 13 41 30

After

Screenshot 2023-12-13 at 13 41 54

Closing this issue as fixed.