DefinitelyTyped / DefinitelyTyped/DefinitelyTyped

[styled-components] forwardRef types are broken when using styled component

Open
#52,216 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
51.4k
Forks
30.4k
Avg merge
3d 21h
Merged PRs (30d)
108

Description

  • I tried using the @types/xxxx package and had problems.
  • I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • I understand that @types package versions do not follow SemVer.
  • Mention the authors (see Definitions by: in index.d.ts) so they can respond.
    • Authors: @Igorbek @Igmat @LavaToaster @Jessidhia @JKillian @eps1lon @flavordaaave @wagerfield @Lazyuki @mgoszcz2 @danilofuchs

I have build a small codesandbox to expose the problem:
https://codesandbox.io/s/lucid-hypatia-g9umr?file=/src/Icon.tsx

I'm a beginner in typescript so it's possible i miss something but i feel it strange that i works perfectly when i use directly the <svg/> but when i use <Svg> but I can not get it to work.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox, especially /src/Icon.tsx, and reproduce the type error using the styled component with forwardRef. Compare it with the direct case; done means the styled-component usage type-checks correctly with the same ref and props behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.