kripod / kripod/react-polymorphic-types

forwardRef and memo examples don't work with Typescript 5.1

Open
#12 0 comments 5 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
197
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Hello!

I tried to update our typescript to 5.1 and now we are seeing errors on our usage of `PolymorphicForwardRefExoticComponent`. The same error also happens with `PolymorphicMemoExoticComponent`

It also errors on playground using the example from the package: [TS Playground with Error](https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAKjgQwM5wEoFNkGN4BmUEIcARFDvmQNwCwAUKJLHDAJ5hZwDejccAAoQANuxDQwAC2C4AYtADuyKABNsBAKIAPCDFkBhEpAB2WEzAA0-IaPGSZuQcTCoA6sBhSIAVxgbrBgFhMQkoaVlnCFcPLw1GAF84IhJySjwYAFpIUIdZTI4uVFpGAHpSuGZoeB44AAkcVWATAHMAESwCZB8RGE0RLBBzK3rG5paAeUUTKNc4JJTSMgA6UobkJtaShkZcCBNUeHXN9s7u3v7B4bgAXjgAcikAJnvGQu5j8amZl3Q7viCcD2ImgAH4AFxwQ5Qcb0BgJOGMLDaFjwd6jDbjWaoAA8NgAKnBkTBzKp0NgMstLkMLPjONw7u8IAQMScOl0en0BjSYIwAHy3Wy5cKObGxKQaHGfVrfbGWOD4vmIhjI1FA-aHVnjSEhewi2QKKDKNQaHR6QzGfbDPGA6WTaZymxMll29nnLlXCz8wUU-DLAhKFTqToACgIPhM+GA+y1rRtAkJxNJ5KoMCp3OGdK4gudsdOHIuGa9DD5IZsAIEAjQgUr6pBUBrlcO7AGjYEyw7lEO2JsCR1djCEScv3Fvn8nSlYxlDt+8sVjcoBEhvrThuNqiwwYIOOpwz5jAAlLwbHsDvBdxZl6n056YFmGSh0AAfJ95t2ci8wOECSgwHxQEw4B3It4EXG4eEXJJmwGcDamBaB5Q7ZZoO4BIkh4JCuxgbEklKJVEgPGggA)

Full Error is:

```ts
Type 'ForwardRefExoticComponent, "ref"> | Omit, HTMLObjectElement>, "ref"> | ... 121 more ... | Omit<...>, "as" | "color"> & HeadingOwnProps & { ...; } & RefAttributes<...>>' is not assignable to type 'PolymorphicForwardRefExoticComponent'.
Type 'ForwardRefExoticComponent, "ref"> | Omit, HTMLObjectElement>, "ref"> | ... 121 more ... | Omit<...>, "as" | "color"> & HeadingOwnProps & { ...; } & RefAttributes<...>>' is not assignable to type ' = "h2">(props: PolymorphicPropsWithRef) => ReactElement> | null'.
Type 'ReactNode' is not assignable to type 'ReactElement> | null'.
Type 'undefined' is not assignable to type 'ReactElement> | null'.
```

my lib versions are:
Typescript: 5.1.3
@types/react: 18.2.14
@types/react-dom: 18.2.6

Thank you

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked TypeScript Playground and the definitions or examples using PolymorphicForwardRefExoticComponent and PolymorphicMemoExoticComponent. Reproduce the errors with TypeScript 5.1.3, @types/react 18.2.14, and @types/react-dom 18.2.6, then identify why the examples no longer type-check. Done means both forwardRef and memo examples compile without the reported ReactNode error.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.