question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v11: TypeScript infers incorrect type when composing styles/classes

See original GitHub issue

Current behavior:

When composing styles the type of the created styled component is inferred to be a union of the created type and any element types referenced in the template literal

To reproduce:

The following code gives a TypeScript error using v11 but not under v10:

const Label = styled.label``
const Input = styled.input`
  & + ${Label}: {
    margin-left: 3px;
  }
`
;<Input onChange={(evt: React.ChangeEvent<HTMLInputElement>) => console.log(evt.target.value)} />

The resultant type becomes HTMLInputElement & HTMLLabelElement (or similar) and so the onChange handler is not allowed

Expected behavior:

In the above code the Input component should be inferred to be just HTMLInputElement

Environment information:

  • react version: 16.11.0
  • emotion version: 11.0.0-next.5

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
Andaristcommented, Dec 8, 2019

It got merged in few minutes ago - I’ll cut a new release soon, so if the fix is already on next I would prefer to close this issue already. Stay tuned for a new release!

2reactions
frankwalliscommented, Dec 11, 2019

I can confirm that our build is now working fine with no changes using v11 (we are not using theming). The build time has gone down from ~38 seconds to ~26 seconds which is really awesome, and I think will have a big impact when using VSCode. Thanks for the great work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

material-ui/core/CHANGELOG.md
- ⚛️ A first step toward converting all the demos to React Hooks (#13873) @adeelibr. 124, - And many more bug fixes and...
Read more >
Angular blob pdf
Angular blob type. ... TYPESCRIPT 2.9 (FEC29FA) 6.1.0 (2018-07-25) Blog post "angular v6.1 is now ... Close # 20406 Compiler: Issuing blocks of...
Read more >
Full text of "Achamenid history XIII"
Achaemenid History VII: Through Travellers' Eyes, Leiden 1991. H. Sancisi-Weerdenburg ... More remarkable still, no other group brings any type of bow.
Read more >
Materialising Ancestral Madang: Pottery Production and ...
This type of social coalescence is documented among other Indian groups as a ... Madang classification 101 Technical attributes 102 Assemblage composition ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found