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 error with TypeScript 5.2.2 #26

Open
GunnarSturla opened this issue Nov 7, 2023 · 1 comment
Open

Type error with TypeScript 5.2.2 #26

GunnarSturla opened this issue Nov 7, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@GunnarSturla
Copy link

First off, thanks for a fantastic package! Long time happy user, first time bug reporter here :)

Description

Updating TypeScript to 5.2.2 (possibly lower versions as well) causes/reveals a type error in the Box component. My guess would be that TS has changes how it resolves the generics, but to be honest, I don't fully understand how this package works.

Reproduction

Take the example Code Sandbox and update the TypeScript version to 5.2.2 in package.json (it might require reloading the tab)

Here's a link to an updated Sandbox showing the error

Expected behavior

Types should work

Actual behavior

Box component shows the following type error

Type '{ as: "h2"; style: { color: string | undefined; } & LibraryManagedAttributes<E, ComponentPropsWithRef<E>>[string]; } & Omit<...> & { ...; }' is not assignable to type 'IntrinsicAttributes & BoxOwnProps<"h2" & HeadingProps<E>["as"]> & Omit<LibraryManagedAttributes<"h2" & HeadingProps<E>["as"], ComponentPropsWithRef<...>>, "as">'.
  Type '{ as: "h2"; style: { color: string | undefined; } & LibraryManagedAttributes<E, ComponentPropsWithRef<E>>[string]; } & Omit<...> & { ...; }' is not assignable to type 'Omit<LibraryManagedAttributes<"h2" & HeadingProps<E>["as"], ComponentPropsWithRef<"h2" & HeadingProps<E>["as"]>>, "as">'.ts(2322)

Environment

All / Code Sandbox

@GunnarSturla GunnarSturla added the bug Something isn't working label Nov 7, 2023
@kripod
Copy link
Owner

kripod commented Mar 22, 2024

Thanks for reporting!

Unfortunately, I’m no longer maintaining this package, but recently wrote an article about how the as prop can be implemented with strong type-safety in place.

Eventually, both this package and react-polymorphic-types should be deprecated in favor of my post above.

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

No branches or pull requests

2 participants