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

type errors with custom Lucide icons when upgrading @types/react/@types/react-dom #585

Open
kahlstrm opened this issue Jan 5, 2025 · 1 comment

Comments

@kahlstrm
Copy link
Contributor

kahlstrm commented Jan 5, 2025

When trying to remove the pnpm.overrides for @types/react and @types/react-dom and running pnpm typecheck, the UI package fails with the following errors:

~/src/github/tietokilta/web/packages/ui (update-next-15-react-19*) » pnpm typecheck

> @tietokilta/ui@0.0.0 typecheck /Users/kalski/src/github/tietokilta/web/packages/ui
> tsc --noEmit

lib/components/navigation-menu/index.tsx:57:6 - error TS2786: 'ChevronDownIcon' cannot be used as a JSX component.
  Its type 'ForwardRefExoticComponent<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>>' is not a valid JSX element type.
    Type 'ForwardRefExoticComponent<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>>' is not assignable to type '(props: any) => ReactNode | Promise<ReactNode>'.
      Type 'ReactNode' is not assignable to type 'ReactNode | Promise<ReactNode>'.
        Type 'ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode | Promise<ReactNode>'.
          Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.

57     <ChevronDownIcon
        ~~~~~~~~~~~~~~~

  ../../node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:387:9
    387         children: ReactNode;
                ~~~~~~~~
    'children' is declared here.

lib/components/sheet/index.tsx:84:12 - error TS2786: 'XIcon' cannot be used as a JSX component.
  Its type 'ForwardRefExoticComponent<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>>' is not a valid JSX element type.
    Type 'ForwardRefExoticComponent<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>>' is not assignable to type '(props: any) => ReactNode | Promise<ReactNode>'.
      Type 'ReactNode' is not assignable to type 'ReactNode | Promise<ReactNode>'.
        Type 'ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode | Promise<ReactNode>'.
          Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.

84           <XIcon className="size-6" />
              ~~~~~

  ../../node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:387:9
    387         children: ReactNode;
                ~~~~~~~~
    'children' is declared here.

lib/icons/index.tsx:149:41 - error TS2344: Type 'IconType' does not satisfy the constraint 'JSXElementConstructor<any> | keyof IntrinsicElements'.
  Type 'ForwardRefExoticComponent<Pick<SVGProps<SVGSVGElement>, "string" | "name" | "target" | "format" | "className" | "type" | "id" | "lang" | "style" | "tabIndex" | "role" | "color" | ... 455 more ... | "zoomAndPan"> & { ...; } & RefAttributes<...>>' is not assignable to type '(props: any) => ReactNode | Promise<ReactNode>'.
    Type 'ReactNode' is not assignable to type 'ReactNode | Promise<ReactNode>'.
      Type 'ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode | Promise<ReactNode>'.
        Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.

149 } & (LucideProps | React.ComponentProps<IconType>);
                                            ~~~~~~~~

  ../../node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:387:9
    387         children: ReactNode;
                ~~~~~~~~
    'children' is declared here.

lib/icons/index.tsx:154:11 - error TS2786: 'IconComponent' cannot be used as a JSX component.
  Its type 'LucideIcon | ForwardRefExoticComponent<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>> | IconType' is not a valid JSX element type.
    Type 'LucideIcon' is not assignable to type 'ElementType'.
      Type 'ForwardRefExoticComponent<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>>' is not assignable to type '(props: any) => ReactNode | Promise<ReactNode>'.
        Type 'ReactNode' is not assignable to type 'ReactNode | Promise<ReactNode>'.
          Type 'ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode | Promise<ReactNode>'.
            Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.

154   return <IconComponent {...props} />;
              ~~~~~~~~~~~~~

  ../../node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:387:9
    387         children: ReactNode;
                ~~~~~~~~
    'children' is declared here.

lib/icons/nav/applicants.tsx:4:7 - error TS2322: Type 'ForwardRefExoticComponent<Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>>' is not assignable to type 'LucideIcon'.
  Types of parameters 'props' and 'props' are incompatible.
    Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>'.
      Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'RefAttributes<SVGSVGElement>'.
        Types of property 'ref' are incompatible.
          Type 'LegacyRef<SVGSVGElement> | undefined' is not assignable to type 'Ref<SVGSVGElement> | undefined'.
            Type 'string' is not assignable to type 'Ref<SVGSVGElement> | undefined'.

4 const NavApplicantsIcon: LucideIcon = React.forwardRef(
        ~~~~~~~~~~~~~~~~~

lib/icons/nav/companies.tsx:4:7 - error TS2322: Type 'ForwardRefExoticComponent<Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>>' is not assignable to type 'LucideIcon'.
  Types of parameters 'props' and 'props' are incompatible.
    Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>'.
      Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'RefAttributes<SVGSVGElement>'.
        Types of property 'ref' are incompatible.
          Type 'LegacyRef<SVGSVGElement> | undefined' is not assignable to type 'Ref<SVGSVGElement> | undefined'.
            Type 'string' is not assignable to type 'Ref<SVGSVGElement> | undefined'.

4 const NavCompaniesIcon: LucideIcon = React.forwardRef(
        ~~~~~~~~~~~~~~~~

lib/icons/nav/events.tsx:4:7 - error TS2322: Type 'ForwardRefExoticComponent<Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>>' is not assignable to type 'LucideIcon'.
  Types of parameters 'props' and 'props' are incompatible.
    Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>'.
      Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'RefAttributes<SVGSVGElement>'.
        Types of property 'ref' are incompatible.
          Type 'LegacyRef<SVGSVGElement> | undefined' is not assignable to type 'Ref<SVGSVGElement> | undefined'.
            Type 'string' is not assignable to type 'Ref<SVGSVGElement> | undefined'.

4 const NavEventsIcon: LucideIcon = React.forwardRef(
        ~~~~~~~~~~~~~

lib/icons/nav/fuksis.tsx:4:7 - error TS2322: Type 'ForwardRefExoticComponent<Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>>' is not assignable to type 'LucideIcon'.
  Types of parameters 'props' and 'props' are incompatible.
    Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>'.
      Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'RefAttributes<SVGSVGElement>'.
        Types of property 'ref' are incompatible.
          Type 'LegacyRef<SVGSVGElement> | undefined' is not assignable to type 'Ref<SVGSVGElement> | undefined'.
            Type 'string' is not assignable to type 'Ref<SVGSVGElement> | undefined'.

4 const NavFuksisIcon: LucideIcon = React.forwardRef(
        ~~~~~~~~~~~~~

lib/icons/nav/guild.tsx:4:7 - error TS2322: Type 'ForwardRefExoticComponent<Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>>' is not assignable to type 'LucideIcon'.
  Types of parameters 'props' and 'props' are incompatible.
    Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>'.
      Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'RefAttributes<SVGSVGElement>'.
        Types of property 'ref' are incompatible.
          Type 'LegacyRef<SVGSVGElement> | undefined' is not assignable to type 'Ref<SVGSVGElement> | undefined'.
            Type 'string' is not assignable to type 'Ref<SVGSVGElement> | undefined'.

4 const NavGuildIcon: LucideIcon = React.forwardRef(
        ~~~~~~~~~~~~

lib/icons/tik-logo.tsx:4:7 - error TS2322: Type 'ForwardRefExoticComponent<Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>>' is not assignable to type 'LucideIcon'.
  Types of parameters 'props' and 'props' are incompatible.
    Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'Omit<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>'.
      Type 'Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>' is not assignable to type 'RefAttributes<SVGSVGElement>'.
        Types of property 'ref' are incompatible.
          Type 'LegacyRef<SVGSVGElement> | undefined' is not assignable to type 'Ref<SVGSVGElement> | undefined'.
            Type 'string' is not assignable to type 'Ref<SVGSVGElement> | undefined'.

4 const TikLogo: LucideIcon = React.forwardRef(
        ~~~~~~~


Found 10 errors in 9 files.

Errors  Files
     1  lib/components/navigation-menu/index.tsx:57
     1  lib/components/sheet/index.tsx:84
     2  lib/icons/index.tsx:149
     1  lib/icons/nav/applicants.tsx:4
     1  lib/icons/nav/companies.tsx:4
     1  lib/icons/nav/events.tsx:4
     1  lib/icons/nav/fuksis.tsx:4
     1  lib/icons/nav/guild.tsx:4
     1  lib/icons/tik-logo.tsx:4
 ELIFECYCLE  Command failed with exit code 2.

Need to figure out what's wrong with the typing so that we can remove the typing override.

@kahlstrm
Copy link
Contributor Author

kahlstrm commented Jan 5, 2025

This can be related: lucide-icons/lucide#2667

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant