kripod / kripod/react-polymorphic-types

How to use with styled components

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

Description

Not strictly an issue of this library but a question about integrating with styled-components.

I have the following piece of code and styled-components is unable to deduce `h1` attributes of `StyledHeading`. With only `as={}` suggested when creating a `StyledHeading` tag and any other attributes being `any`. Upon checking the typing from my IDE, I see that `StyledHeading` has type `StyledComponent, ...>`.

```ts
import styled from 'styled-components'

export const Heading: PolymorphicForwardRefExoticComponent<
HeadingOwnProps,
typeof HeadingDefaultElement
>(...) => {...}

const StyledHeading = styled(Heading).attrs({
forwardedAs: 'h1' // or as: 'h1'
})``
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the TypeScript example in the issue with styled-components and inspect the inferred type of StyledHeading. The issue names no repository files or tests; done would require a documented or verified integration path that preserves the intended h1 attributes.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.