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

Props not assignable to LibraryManagedAttributes type error #3261

Open
shawnrivers opened this issue Sep 30, 2024 · 3 comments
Open

Props not assignable to LibraryManagedAttributes type error #3261

shawnrivers opened this issue Sep 30, 2024 · 3 comments

Comments

@shawnrivers
Copy link

shawnrivers commented Sep 30, 2024

Current behavior:

After updating @emotion/react to 11.13.3, I start seeing the following type error in HOC (higher-order components):

src/hoc.tsx:7:13 - error TS2322: Type 'P' is not assignable to type 'IntrinsicAttributes & LibraryManagedAttributes<FC<P>, P>'.
  Type 'Record<string, unknown>' is not assignable to type 'IntrinsicAttributes & LibraryManagedAttributes<FC<P>, P>'.
    Type 'Record<string, unknown>' is not assignable to type 'LibraryManagedAttributes<FC<P>, P>'.
      Type 'P' is not assignable to type 'LibraryManagedAttributes<FC<P>, P>'.
        Type 'Record<string, unknown>' is not assignable to type 'LibraryManagedAttributes<FC<P>, P>'.

7     return <C {...props} />;
              ~


Found 1 error in src/hoc.tsx:7

Here is the code that produces this type error above:

const Component: React.FC<{ children: React.ReactNode }> = ({ children }) => {
  return <div>{children}</div>;
};

export const hoc = <P extends Record<string, unknown>>(C: React.FC<P>) => {
  return (props: P) => {
    return <C {...props} />;
  };
};

hoc(Component);

After downgrading @emotion/react to 11.13.0, the error stops appearing anymore.

To reproduce:

  1. Clone this repository for reproduction: https://github.com/shawnrivers/emotion-react-hoc-type-error
  2. Run npm i
  3. Run npm run type-check

Expected behavior:

No type error inside the HOC (which is the behavior before @[email protected].

Environment information:

  • react version: 18.3.1
  • @emotion/react version: 11.13.3
@ENvironmentSet
Copy link
Contributor

ENvironmentSet commented Oct 2, 2024

Duplicated: #3245

@kenshanta
Copy link

@shawnrivers shall we close this?

@shawnrivers
Copy link
Author

@kenshanta No problem.

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