Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: IconButton triggers a compilation error when passed a React-Router-Dom Link component for as attribute #1490

Closed
yhafez opened this issue May 23, 2024 · 0 comments · Fixed by #1494
Assignees
Labels
bug Something isn't working
Milestone

Comments

@yhafez
Copy link
Contributor

yhafez commented May 23, 2024

Steps to reproduce

Create a valid IconButton component and pass it a Link component for the as attribute.

Expected Behavior

The IconButton renders properly using a Link React-Router-Dom component as the component it renders. It does not cause a linter error or a compilation error.

Actual Behavior

A linter error and compilation error occur.

Version

6.4.0

What browsers are you experiencing the problem on?

No response

Relevant log output

Linter error:

Type '<S = H.LocationState>(props: LinkProps<S> & RefAttributes<HTMLAnchorElement>) => ReactElement<any, string | JSXElementConstructor<any>> | null' is not assignable to type '(("button" | "a") & (<S = H.LocationState>(props: LinkProps<S> & RefAttributes<HTMLAnchorElement>) => ReactElement<any, string | JSXElementConstructor<any>> | null)) | undefined'.
  Type '<S = H.LocationState>(props: LinkProps<S> & RefAttributes<HTMLAnchorElement>) => ReactElement<any, string | JSXElementConstructor<any>> | null' is not assignable to type '"button" & (<S = H.LocationState>(props: LinkProps<S> & RefAttributes<HTMLAnchorElement>) => ReactElement<any, string | JSXElementConstructor<any>> | null)'.
    Type '<S = H.LocationState>(props: LinkProps<S> & RefAttributes<HTMLAnchorElement>) => ReactElement<any, string | JSXElementConstructor<any>> | null' is not assignable to type '"button"'.ts(2322)
polymorphicComponent.d.ts(4, 5): The expected type comes from property 'as' which is declared here on type 'IntrinsicAttributes & Omit<LinkProps<unknown> & RefAttributes<HTMLAnchorElement>, keyof IconButtonProps> & IconButtonProps & { ...; }'
(property) as?: (("button" | "a") & (<S = H.LocationState>(props: LinkProps<S> & React.RefAttributes<HTMLAnchorElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null)) | undefined

Compilation error:

ERROR in ./src/modules/axe-watcher/components/projects/ProjectRow.tsx:76:9
TS2322: Type '<S = H.LocationState>(props: LinkProps<S> & RefAttributes<HTMLAnchorElement>) => ReactElement<any, string | JSXElementConstructor<any>> | null' is not assignable to type '(("a" | "button") & (<S = H.LocationState>(props: LinkProps<S> & RefAttributes<HTMLAnchorElement>) => ReactElement<any, string | JSXElementConstructor<any>> | null)) | undefined'.
    74 |     <div className={styles.actions}>
    75 |       <IconButton
  > 76 |         as={Link}
       |         ^^
    77 |         to={url}
    78 |         icon="eye"
    79 |         label={t('View {{name}}', { name: project.name })}

Anything else we should know?

Additional information

Noticed in Walnut when attempting to update to latest version of cauldron

@yhafez yhafez added the bug Something isn't working label May 23, 2024
@scurker scurker self-assigned this May 29, 2024
@scurker scurker added this to the Q2 2024 milestone Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants