v11: TypeScript infers incorrect type when composing styles/classes
See original GitHub issueCurrent 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:
- Created 4 years ago
- Comments:12 (12 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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!
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!