kripod / kripod/react-polymorphic-types
`ref` element type not inferred correctly
- Dominant language
- No language data
- Stars
- 197
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
Hi, great library, thanks for creating it! I'm using it in [React Interactive](https://github.com/rafgraph/react-interactive)
Using the `Heading` `forwardRef` example in the readme the `ref` element type implicitly is `any`:
For a live reproduction see: https://codesandbox.io/s/polymorphic-inferred-ref-type-zqyl6
```ts
{}}
>
As h1
```
Note that when creating a props object to pass to `Heading` the `ref` element type is inferred correctly:
```ts
const propsForHeading: HeadingProps<"h1"> = {
// element type is inferred correctly
ref: (element) => {},
children: "Heading using propsForHeading"
};
...
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Heading forwardRef example in the README and compare it with the linked CodeSandbox reproduction. Investigate why the inline ref callback loses the element type while a HeadingProps<"h1"> props object infers it correctly; done means the inline callback receives the appropriate h1 element type without an explicit annotation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100