Emotion 10 intrinsics typescript types do not have event handler props
See original GitHub issueemotion
version: 10.0.4react
version: 16.7.0-alpha.2
Relevant code:
const Form = styled.form({})
const Foo = () => <Form onSubmit={e => { console.log(e) }} />
What you did:
Upgraded to Emotion 10
What happened:
Intrinsics created by styled
do not appear to have event handler props like onSubmit
/onChange
so typescript complains about the implicit any of e
.
error TS7006: Parameter 'event' implicitly has an 'any' type.
Reproduction:
Codesandbox doesn’t import emotion types, so it’s not helpful to repro. If there’s a way to make that work, or if there’s a starter project w/ Typescript + emotion 10 I’d gladly whip up a repro.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
TypeScript - Emotion
When using our JSX factory, TypeScript only allows the css prop on components that accept a className prop. This is because @emotion/react resolves...
Read more >React TypeScript | Correct Type for Event Handler Prop
The easiest solution would be to use the MouseEventHandler type with HTMLButtonElement as the type parameter: interface ButtonProps { play: ...
Read more >CHANGELOG.md - mui/material-ui - Sourcegraph
Change all occurrences of components and componentsProps props in Base components to slots and slotProps, respectively. Change casing of slots' fields to ...
Read more >property 'children' does not exist on type 'intrinsicattributes'.ts ...
I have replaced the key prop as it is not recommended to use indexes as keys ... Property children does not exist on...
Read more >Understanding and improving Emotion 10's TypeScript types
We have this ExtraProps generic argument already, it allows us to make extra props available to the styles, but not require them to...
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 looks like that will work for me. I don’t need it to accept functions because these are for functions that return styles.
By the way,
CSSPropertiesWithMutliValues
is misspelledMutli
vsMulti
.Looks like all I need now to upgrade to emotion 10 would be the above new type,
innerRef
support (I may be missing something here) and the babel jsx pragma eliding fix.@Ailrun here you go: https://github.com/emotion-js/emotion/pull/1098