kripod / kripod/react-polymorphic-box
Type error with TypeScript 5.2.2
- Vorherrschende Sprache
- TypeScript
- Sterne
- 347
- Forks
- 14
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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](https://codesandbox.io/s/react-polymorphic-box-forwarding-refs-forked-yfg4vj?file=/src/App.tsx)
## Expected behavior
Types should work
## Actual behavior
`Box` component shows the following type error
```
Type '{ as: "h2"; style: { color: string | undefined; } & LibraryManagedAttributes>[string]; } & Omit<...> & { ...; }' is not assignable to type 'IntrinsicAttributes & BoxOwnProps<"h2" & HeadingProps["as"]> & Omit["as"], ComponentPropsWithRef<...>>, "as">'.
Type '{ as: "h2"; style: { color: string | undefined; } & LibraryManagedAttributes>[string]; } & Omit<...> & { ...; }' is not assignable to type 'Omit["as"], ComponentPropsWithRef<"h2" & HeadingProps["as"]>>, "as">'.ts(2322)
```
## Environment
All / Code Sandbox
Beitragsleitfaden
Rechercherichtung
Reproduziere den Fehler in der verknüpften CodeSandbox, indem du package.json auf TypeScript 5.2.2 aktualisierst. Beginne bei der polymorphen generischen Typisierung der Box-Komponente und prüfe, wie ihre Props mit dieser TypeScript-Version aufgelöst werden. Fertig ist die Aufgabe, wenn das Beispiel ohne den gemeldeten Fehler eine Typprüfung besteht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- react, typescript
- Bereich
- frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100